我有asp.net mvc项目,它的结构和路由如下。
“Site.Master”包含图片和css文件,路径为:
访问“http://www.localhost.com/Info/Index/1001”页面时,它可以正常工作。
但是页面“http://www.localhost.com/Info/Index/1001/1”或“http://www.localhost.com/Info/Index/1001/2”,请不要。
我修改了Site.Master中的图像和css文件路径,如:
此外,还有另一种方法可以修复它吗?或修改路由?因为,我想在iis中使用虚拟目录进行部署。
- >图像
- >含量
- >观点
主页
- index.aspx
信息
- index.aspx
共享
- Site.Master
routes.MapRoute( “InfoPagedRoute” “{控制器} / {行动} / {的classid} / {页}”, new {controller =“Info”,action =“Index”,classid = @“\ d {1,10}”,page = 1} );
答案 0 :(得分:0)
您的原始路线:
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的route debugger。确定您希望被击中的路线是否实际上是正在使用的路线,这确实很有帮助。