生产环境中的 ASP.NET 路由
我已在 RouteTable.Routes
中注册了自定义 asp.net 路由。
routes.MapPageRoute(
"View Service",
"home/services/{*ServiceName}",
"~/home/displayservice.aspx"
);
我的应用程序使用 ASP.NET 4.0 路由系统,当我从 Visual Studio 运行网站进行调试时,在开发计算机上一切正常。
当我将站点移至 IIS7 时,导航到路由
http://new.komplus.ua/home/services/viruses/antivirus/
系统或应由路由系统处理的任何其他路径时不会发生路由。结果,我从服务器收到 404 错误。
我确信我已将 global.asax 和 /home/displayservice.aspx
复制到 Web 服务器,并在更新后重新启动了网站和应用程序池,但路由仍然不执行地方。
其他非路由页面可以正常加载。
与 VS2010 调试环境相比,是否需要对 IIS 进行任何特定配置才能使 ASP.NET 4 路由正常工作?
I have registered a custom asp.net route in a RouteTable.Routes
.
routes.MapPageRoute(
"View Service",
"home/services/{*ServiceName}",
"~/home/displayservice.aspx"
);
My application uses ASP.NET 4.0 routing system, and everything works fine on a development machine, when I run the web site from Visual Studio to debug.
When I move the site to IIS7, the routing isn't happening when navigating to
http://new.komplus.ua/home/services/viruses/antivirus/
or any other path that supposed to be handled by the routing system. As a result, I get 404 error from the server.
I am sure I have copied the global.asax and the /home/displayservice.aspx
to the web server, and have restarted the web site and app pool since update, but the routing still doesn't take place.
Other, non-routed pages, load fine.
Is there any particular configuration to IIS that has to be done in order for ASP.NET 4 routing to work, in comparison to VS2010 debug environment?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使 ASP.NET 4.0 路由能够在 IIS7 中工作,需要在 web.config 中清除 webServer 元素。例如:
在 Visual Studio 环境中这不是必需的,即使 web.config 中没有此指令,路由也会发生。
In order for ASP.NET 4.0 routing to work in IIS7 it is requried that the web.config has the webServer element decleared. For examle:
It is not a requirement in Visual Studio environment, where routing takes place even without this directive in web.config.