ASP.Net MVC2 路由可选参数给出 404
我们有 MVC2 映射...
routes.MapRoute(
"HomeKeepAlive",
"{controller}/KeepAlive/{objectType}/{id}",
new { controller = "Home", action="KeepAlive", objectType = UrlParameter.Optional, id = UrlParameter.Optional }
);
routes.MapRoute(
"DefaultRoute",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
所有服务器都是 Windows Server 2003 sp2、IIS6,安装了 .Net 4。
路由在我们的测试服务器上工作
/Home/Ping
/Home/Ping/1
/Home/KeepAlive/Article
/Home/KeepAlive/Article/5
但是在我们的实时服务器上只有没有 id 的 url 工作,例如,
/Home/Ping
/Home/KeepAlive/Article
而那些有 id 的 url 给出 404
/Home/Ping/1
/Home/KeepAlive/Article/5
鉴于测试服务器工作正常,我假设问题是我们现场的 IIS6 的配置问题服务器,但我看不出它们之间有任何区别。
以前有人见过这样的事情吗?
We have the MVC2 mappings...
routes.MapRoute(
"HomeKeepAlive",
"{controller}/KeepAlive/{objectType}/{id}",
new { controller = "Home", action="KeepAlive", objectType = UrlParameter.Optional, id = UrlParameter.Optional }
);
routes.MapRoute(
"DefaultRoute",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
All servers are Windows Server 2003 sp2, IIS6 with .Net 4 installed.
The routings work on our test server
/Home/Ping
/Home/Ping/1
/Home/KeepAlive/Article
/Home/KeepAlive/Article/5
But on our live server only urls without an id work, eg
/Home/Ping
/Home/KeepAlive/Article
whilst those with an id give a 404
/Home/Ping/1
/Home/KeepAlive/Article/5
Given that the test server works I'm assuming that the problem is a cofiguration issue with IIS6 on our live server, but I can't see any differences between them.
Has anyone seen anything like this before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看这篇文章< /a> 查找最近引入的 ASP.net 中的错误,该错误可能会导致您的问题。
Check out this post for a bug in ASP.net, introduced recently, that may be causing your problem.
看看这个: 选项-用于部署 aspnet-mvc-to-iis-6
Check this out: options-for-deploying-aspnet-mvc-to-iis-6