Model view controller 如何修改路由?
我有一个asp.NETMVC项目,它的结构和路径如下 “Site.Master”包括图像和css文件,路径为: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”“不要 我修
- ../../Images/1.gif
- ../../Content/site.css
- /图片/1.gif
- /Content/site.css
- 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的。这对于确定你期望被击中的路线是否就是正在使用的路线非常有帮助