asp.net MVC - 默认路由似乎不起作用
我已经设置了一些路线,它们可以工作,所以如果我把 localhost/MyWebApp/Reservas ......它可以工作。
我已经设置了一个默认路由,如果有人输入 localhost/MyWebApp 它应该直接进入 Reservas 路由...但事实并非如此..
我已经安装了一个路由调试器,但似乎没有任何内容与请求匹配..我在做什么有事吗?
你能帮忙吗? ...这是我的路线..注意最后一条路线是默认路线,我认为应该启动并通过 Reservas 路线发送给我
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Reservas", // Route name
"Reservas/{action}/{jsonData}", // URL with parameters
new {controller = "Reservation", action = "Index", jsonData="" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"Reservas/{action}/{jsonData}", // URL with parameters
new { controller = "Reservation", action = "Index", jsonData = "" } // Parameter defaults
);
I have setup some routes and they work so if i put localhost/MyWebApp/Reservas ...... it works.
I have setup up a default route that if somebody enter localhost/MyWebApp it should go directly to the Reservas route ... but it doesn't..
I have installed a route debugger and it appears nothing matches the request.. am i doing something wrong?
Can you help? ... here is my routes .. notice the last route is the DEFAULT route that i preusume should kick in and send me via the Reservas route
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Reservas", // Route name
"Reservas/{action}/{jsonData}", // URL with parameters
new {controller = "Reservation", action = "Index", jsonData="" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"Reservas/{action}/{jsonData}", // URL with parameters
new { controller = "Reservation", action = "Index", jsonData = "" } // Parameter defaults
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当 URL 类似于
/MyWebApp/Reservas
时,您当前的默认路由才会匹配。您应该将其更改为如下所示:Your current default route will only match when the URL looks something like
/MyWebApp/Reservas
. You should change it to look something like this: