locked
AJAX Timer control working on Localhost but not on server RRS feed

  • Question

  • User1540670854 posted

    Reference Page: https://www.raefkobeissi.com/bb/index2.aspx
    I would like first to thank:mgebhard and Brando ZWZfor helping me so far with another thread regarding Timer Control. I managed to make a label incrementally update every tick by using Shared variables. It worked perfectly fine on my localhost ( Using Visual Studio 2017 Community) but unfortunately when I uploaded my test project to the server it just didn't work!

    Note: The server I am using is hosted by smarterasp.net, I've created many aspx pages in the past and they all worked fine. I asked them if their server support AJAX and they said yes. 

    In Summary:

    HTML Page including the script:

    <script runat="server">
        Shared C = 0
        Protected Sub Button1_Click(sender As Object, e As EventArgs)
            Timer1.Interval = 1000
            Timer1.Enabled = True
        End Sub
    
        Protected Sub Timer1_Tick(sender As Object, e As EventArgs)
           c=c+1
            Label1.Text = c
        End Sub
    </script>
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>
    
    <body>
    
        <form id="form1" runat="server">
              <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
              <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
     <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
    </Triggers>
                  <ContentTemplate>
    <div style="; width: 622px; height: 365px; z-index: 1; left: 758px; top: 99px" id="layer1">
    	<div style="; width: 100px; height: 46px; z-index: 1; left: -153px; top: 271px" id="layer6">
    &nbsp;</div>
    	<div style="; width: 100px; height: 46px; z-index: 1; left: -154px; top: 205px" id="layer5">
    &nbsp;</div>
    	<div style="; width: 100px; height: 46px; z-index: 1; left: -154px; top: 135px" id="layer4">
    &nbsp;</div>
    	<div style="; width: 100px; height: 46px; z-index: 1; left: -155px; top: 72px" id="layer3">
    &nbsp;<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </div>
    	<div style="; width: 100px; height: 46px; z-index: 1; left: -156px; top: 11px" id="layer2">
    &nbsp;<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        </div>
    	<p>&nbsp;</div>
    
          </ContentTemplate>
           </asp:UpdatePanel>
    
            <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick">
            </asp:Timer>
            
           
    
        </form>
    
    </body>
    
    </html>
    
    
    
    

    Web.config File: 

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      https://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <system.web>
        <compilation strict="false" explicit="true" targetFramework="4.6.1" />
        <httpRuntime targetFramework="4.6.1" />
      </system.web>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
        </compilers>
      </system.codedom>
    </configuration>
    <!--ProjectGuid: 1C5EE324-242B-41FF-BCA9-9833993836F4-->

    I honestly am not sure what have I done wrong! On my localhost it is working perfectly fine! no errors!

    Debugging from browser under CONSOLE:
    Failed to load resource: the server responded with a status of 404 (Not Found)
    ScriptResource.axd:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    ScriptResource.axd:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    ScriptResource.axd:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    ScriptResource.axd:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    index2.aspx:48 Uncaught ReferenceError: Sys is not defined
    at index2.aspx:48
    index2.aspx:80 Uncaught ReferenceError: Sys is not defined
    at index2.aspx:80

    Tuesday, June 19, 2018 1:10 PM

Answers

  • User475983607 posted

    The error indicates the script manager did not create the AJAX JavaScript libraries.  It could be you are using a newer version, an older version, or the AJAX toolkit is not installed in the host.  It can also be that you are accessing the AJAX toolkit from the GAC and need to deploy the dll in the bin because the host does no have the tool kit installed in the GAC.

    Note: The server I am using is hosted by smarterasp.net, I've created many aspx pages in the past and they all worked fine. I asked them if their server support AJAX and they said yes. 

    AJAX is not the same thing as the AJAX Toolkit.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 19, 2018 10:59 PM
  • User1540670854 posted

    <
    Hi again, after hours of research I managed to fix it :<asp:ScriptManager ID="cdnScriptManager" EnableCdn="true" runat="server">
    </asp:ScriptManager> I was missing the EnableCdn=“true” part in the scriptmanager, once I added this it worked perfectly fine!
    Thank you everyone for your help. I love this Forum!
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 19, 2018 11:09 PM

All replies

  • User753101303 posted

    Hi,

    If looking at the 404 url you see it is loaded from /bb/WebResource.axd ? Could it be that in dev mode you are developping inside a "bb" root application and hardcoded your path for this situation while not having this extra "bb" level on your production site ?

    Tuesday, June 19, 2018 1:27 PM
  • User1540670854 posted

    <g class="gr_ gr_5 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="5" data-gr-id="5">Thanks</g> PatriceSc. I checked that. It is not the problem.

    Tuesday, June 19, 2018 9:27 PM
  • User475983607 posted

    The error indicates the script manager did not create the AJAX JavaScript libraries.  It could be you are using a newer version, an older version, or the AJAX toolkit is not installed in the host.  It can also be that you are accessing the AJAX toolkit from the GAC and need to deploy the dll in the bin because the host does no have the tool kit installed in the GAC.

    Note: The server I am using is hosted by smarterasp.net, I've created many aspx pages in the past and they all worked fine. I asked them if their server support AJAX and they said yes. 

    AJAX is not the same thing as the AJAX Toolkit.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 19, 2018 10:59 PM
  • User1540670854 posted

    <
    Hi again, after hours of research I managed to fix it :<asp:ScriptManager ID="cdnScriptManager" EnableCdn="true" runat="server">
    </asp:ScriptManager> I was missing the EnableCdn=“true” part in the scriptmanager, once I added this it worked perfectly fine!
    Thank you everyone for your help. I love this Forum!
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 19, 2018 11:09 PM