【发布时间】:2015-07-26 16:53:41
【问题描述】:
在我的 MVC 项目中,我在 RouteConfig.Cs 中使用此代码
routes.MapRoute(
name: "Signin",
url: "login/{ReturnUrl}",
defaults: new { controller = "Account", action = "Signin", ReturnUrl = UrlParameter.Optional }
);
但是当我从另一个页面浏览登录页面时,url 不能正常工作,例如:
localhost:43773/account/signin?ReturnUrl=anotherpage
我希望:localhost:43773/login/anotherpage
我该如何解决这个问题?
【问题讨论】:
-
AFAIK,你不能。这是因为两者都被视为等价物。
-
我编辑我的帖子,我期望:localhost:43773/account/login/anotherpage
-
localhost:43773/account/signin?ReturnUrl=anotherpage与该路由不匹配。您指定的路由以“login/”开头,并且有一个参数 -
我编辑我的帖子,我期望:localhost:43773/login/anotherpage
-
这是错误的做法,你会丢失你的查询字符串值,通常 ReturnUrl 编码的查询字符串值必须在重定向后保留。您是否有计划正确转发查询字符串?
标签: asp.net-mvc asp.net-mvc-5.2