Asp.net mvc 2 ASP.Net MVC2路由可选参数给出404

Asp.net mvc 2 ASP.Net MVC2路由可选参数给出404,asp.net-mvc-2,iis-6,asp.net-mvc-routing,Asp.net Mvc 2,Iis 6,Asp.net Mvc Routing,我们有MVC2映射 routes.MapRoute( "HomeKeepAlive", "{controller}/KeepAlive/{objectType}/{id}", new { controller = "Home", action="KeepAlive", objectType = UrlParameter.Optional, id = UrlParameter.Optional } ); routes.MapRoute( "DefaultRoute", "{c

我们有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 }
);
所有服务器都是安装了.Net 4的Windows Server 2003 sp2、IIS6

路由在我们的测试服务器上工作

/Home/Ping

/Home/Ping/1

/Home/KeepAlive/Article

/Home/KeepAlive/Article/5
但在我们的实时服务器上,只有不带id的URL才能工作,例如

/Home/Ping
/Home/KeepAlive/Article
而那些有身份证的人给404分

/Home/Ping/1
/Home/KeepAlive/Article/5
考虑到测试服务器正常工作,我假设问题是我们的实时服务器上IIS6的配置问题,但我看不出它们之间有任何区别


以前有人看到过类似的情况吗?

检查ASP.net中最近引入的可能导致您出现问题的错误。

检查此错误:

谢谢。我用史蒂夫的书作为设置服务器的基础。很有趣。我们是MVC2而不是3,但我将尝试为id为和不带id的创建单独的路由。如上所述,它在测试服务器上运行良好。错误并不真正存在于MVC,而是System.Web.Routing。创建两条路由将解决您的问题。两条路由无法解决问题。它仍然无法拾取需要id的路由。也许睡个好觉后会更容易。live server是IIS中的一个站点,而测试服务器是一个虚拟目录。我有一个简单的解决方法。添加额外的“虚拟”url参数。在实时服务器上,id url参数现在可以识别,例如\Home\Ping\1现在可以工作。如果您尝试\Home\Ping\1\2,它会给出一个404,但我没有任何带有额外参数的URL。我仍然不明白为什么live server会有这种行为。这并不能使我充满信心。新的映射是。。。MapRoute(“默认值”、“{controller}/{action}/{id}/{dummy}”、新的{controller=“Home”、action=“Index”、id=urlparmeter.Optional、dummy=urlparmeter.Optional});