【问题标题】:ASP.NET routing in production evironment生产环境中的 ASP.NET 路由
【发布时间】:2011-11-30 20:49:15
【问题描述】:

我在RouteTable.Routes 中注册了一个自定义的asp.net 路由。

routes.MapPageRoute(
            "View Service",                    
            "home/services/{*ServiceName}", 
            "~/home/displayservice.aspx"   
        );

当我从 Visual Studio 运行网站进行调试时,我的应用程序使用 ASP.NET 4.0 路由系统,并且在开发机器上一切正常。

当我将站点移动到 IIS7 时,导航到时没有发生路由

http://new.komplus.ua/home/services/viruses/antivirus/

或任何其他应该由路由系统处理的路径。结果,我从服务器收到 404 错误。

我确定我已将 global.asax 和 /home/displayservice.aspx 复制到网络服务器,并在更新后重新启动了网站和应用程序池,但路由仍然没有发生。

其他非路由页面,加载正常。

与 VS2010 调试环境相比,是否需要对 IIS 进行任何特定配置才能使 ASP.NET 4 路由正常工作?

【问题讨论】:

    标签: iis-7 url-routing asp.net-routing


    【解决方案1】:

    为了让 ASP.NET 4.0 路由在 IIS7 中正常工作,需要在 web.config 中清除 webServer 元素。例如:

    <system.webServer>     
      <modules runAllManagedModulesForAllRequests="true">     
       </modules>     
    </system.webServer> 
    

    这在 Visual Studio 环境中不是必需的,即使在 web.config 中没有此指令也会进行路由。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-19
      • 2015-12-06
      • 1970-01-01
      • 2012-08-16
      • 2019-01-16
      • 2012-05-21
      • 1970-01-01
      相关资源
      最近更新 更多