Model view controller 如何修改路由?

Model view controller 如何修改路由?,model-view-controller,routes,Model View Controller,Routes,我有一个asp.NETMVC项目,它的结构和路径如下 “Site.Master”包括图像和css文件,路径为: ../../Images/1.gif ../../Content/site.css 当浏览网页时“http://www.localhost.com/Info/Index/1001”他说 但是佩奇”http://www.localhost.com/Info/Index/1001/1“或”http://www.localhost.com/Info/Index/1001/2”“不要 我修

我有一个asp.NETMVC项目,它的结构和路径如下

“Site.Master”包括图像和css文件,路径为:

  • ../../Images/1.gif
  • ../../Content/site.css
当浏览网页时“http://www.localhost.com/Info/Index/1001”他说

但是佩奇”http://www.localhost.com/Info/Index/1001/1“或”http://www.localhost.com/Info/Index/1001/2”“不要

我修改了站点中的图像和css文件路径。如:

  • /图片/1.gif
  • /Content/site.css
此外,还有其他方法修复它吗?或者修改路由吗?因为我想在iis中使用虚拟目录部署它

->图像

  • 1.gif
  • 2.jpg
->内容

  • site.css
->观点

  • --index.aspx

  • 信息

    --index.aspx

  • 共享

    --地点,主人

    routes.MapRoute( “InfoPageDroote”, “{controller}/{action}/{classid}/{page}”, 新的{controller=“Info”,action=“Index”,classid=@“\d{1,10}”,page=1} );

您的原始路线:

routes.MapRoute(
     "InfoPagedRoute",
     "{controller}/{action}/{classid}/{page}", 
     new { controller = "Info", action = "Index", classid = @"\d{1,10}", page = 1 } 
);
看起来您正在尝试在classid的路由默认值中使用验证器,因此您需要包含验证参数或为classid设置默认值

我建议:

routes.MapRoute(
     "InfoPagedRoute",
     "{controller}/{action}/{classid}/{page}", 
     new { controller = "Info", action = "Index", classid = 1001, page = 1 } 
);
如果更新路线不能解决问题,您可以使用Phil Haack的。这对于确定你期望被击中的路线是否就是正在使用的路线非常有帮助