Question

I have .NET 4.0 and .NET 2.0 installed in my computer I tried running a AJAX.NET application with Asynchronous Triggered Timer Tick function and my page is reloading i.e. (Asynchronouspostback is not working). I tried changing my App Pool to Classic .NET 4.0 and I am getting error

HTTP Error 404.2 - Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.

And when I change my App Pool to Classic .NET 2.0 page is being displayed but being postback'd upon timer intervals.

Is there anything more I should add to my Web.Config file

<configuration>
    <system.web>
    <pages enableEventValidation="false" enableViewState="false" enableViewStateMac="false">
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </controls>
    </pages>
        <httpRuntime maxRequestLength="32768" executionTimeout="3600"/>
    <httpHandlers>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
    </httpHandlers>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>
    <compilation defaultLanguage="c#" debug="false">
      <assemblies>
        <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>
    </system.web>
</configuration>

and my AJAX.NET code is

        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
        <asp:Timer ID="Timer1" runat="server" Interval="200" ontick="Timer1_Tick" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
        </asp:UpdatePanel>
Was it helpful?

Solution

You can fix the isapi and cgi restrictions problem by opening IIS Manager, select the server, and double-clicking on the ISAPI and CGI Restrictions icon (assuming win 7 or win server 2008).

In the resulting screen, right click on each entry for ASP.NET v2.0.50727 (assuming a 64-bit OS; will only be one in 32-bit), select Edit... and check the Allow extension path to execute checkbox.

This should allow ASP.Net 2.0 apps to run.

As far as the page posting back, the best suggestion is to wrap it in a separate update panel:

<asp:UpdatePanel runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false"
    ID="upTimer">
    <ContentTemplate>
        <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick" />
    </ContentTemplate>
</asp:UpdatePanel>

You may also want to consider increasing the timer interval from 200 milliseconds unless you absolutely need it that often (I have modified it above to be 2 seconds).

There is also one other setting to check: if you migrated this app from a .Net 1.1 application, you may have the <xhtmlConformance mode="Legacy" /> tag left over in your web.config.

If this is the case, this will absolutely cause this problem, as reported by Scott Guthrie of Microsoft fame.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top