MVC3 MapRoute,带斜杠的参数
我如何创建一个接受斜杠而不将其视为新参数的 MapRoute? 如果 url 是
http://localhost/root/p1/default.aspx
我想要一个参数来获取 localhost (root/p1/default.aspx) 之后的所有内容。通常需要三个参数,因为有两个斜杠,而maproute通过斜杠分隔参数。 因此,如果路由看起来像这样
routes.MapRoute(
"URLMapRoute",
"{path}",
new { controller = "Home", action = "Index", path = "default.aspx" }
);
,那么{path} 就会拾取所有内容,即使 url 包含斜杠。
How would i create a MapRoute that accepts slashes without considering it a new parameter?
If the url is
http://localhost/root/p1/default.aspx
I want one parameter to pick up everything after localhost (root/p1/default.aspx). Normally it would take three parameters for this because there are two slashes, and maproute separates the parameters by slash.
So if the route looks something like
routes.MapRoute(
"URLMapRoute",
"{path}",
new { controller = "Home", action = "Index", path = "default.aspx" }
);
then {path} picks up everything, even though the url contains slashes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用包罗万象的路线:
然后:
You could use a catchall route:
and then: