1

我的计算机中安装了 .NET 4.0 和 .NET 2.0 我尝试运行具有异步触发定时器滴答功能的 AJAX.NET 应用程序,并且我的页面正在重新加载,即(异步回发不工作)。我尝试将我的应用程序池更改为Classic .NET 4.0,但出现错误

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.

当我将我的应用程序池更改为Classic .NET 2.0页面时,正在显示但在计时器间隔后被回发。

还有什么我应该添加到我的 Web.Config 文件中的吗

<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>

我的 AJAX.NET 代码是

        <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>
4

1 回答 1

1

您可以通过打开 IIS 管理器、选择服务器并双击 ISAPI 和 CGI​​ 限制图标(假设 win 7 或 win server 2008)来修复 isapi 和 cgi 限制问题。

在结果屏幕中,右键单击 ASP.NET v2.0.50727 的每个条目(假设是 64 位操作系统;只有 32 位操作系统),选中Edit...并选中Allow extension path to execute复选框。

这应该允许 ASP.Net 2.0 应用程序运行。

至于回发的页面,最好的建议是将其包装在单独的更新面板中:

<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>

您可能还需要考虑将计时器间隔从 200 毫秒增加到 200 毫秒,除非您绝对经常需要它(我在上面将其修改为 2 秒)。

还有一个其他设置需要检查:如果您从 .Net 1.1 应用程序迁移此应用程序,您<xhtmlConformance mode="Legacy" />的 web.config 中可能会留下标记。

如果是这样的话,这绝对会导致这个问题,正如微软成名的 Scott Guthrie 所报道的那样。

于 2012-01-12T18:45:12.393 回答