【发布时间】:2013-11-29 18:21:21
【问题描述】:
我正在尝试让我的网站在成功登录时运行重定向。我将所有会员路线都保存在一个区域中。
/membership/login/index
/membership/profile/index
我已经尝试了以下两种方法来尝试使其正常工作 - 登录成功,但重定向除了更改地址之外没有任何作用。我尝试了以下方法,但结果都一样
[HttpPost]
public ActionResult Index(Login loginViewModel)
{
...
return RedirectToRoute(new { Area = "Membership",
Controller = "Profile", Action="Index" });
}
结果
http://mysite.com/Membership/Login?ReturnUrl=%2fmembership%2fProfile
那么我的下一个努力
return RedirectToAction("Index", "Profile", new { Area = "Membership" });
....
http://mysite.com/Membership/Login?ReturnUrl=%2fmembership%2fProfile
最后
return RedirectToAction("Index", "Profile");
...
http://mysite.com/Membership/Login?ReturnUrl=%2fmembership%2fProfile
【问题讨论】:
-
HTTP POST 无法重定向。但除了将其更改为 GET 之外,我不知道解决方法。如果你把它改成
HttpGet,会发生什么? -
谢谢,很高兴知道,我不太了解http的来龙去脉
-
您的登录好像没有成功。您总是重定向回再次登录。你能显示你的 ActionResut 的完整代码吗?
-
我已经调试过了,示例中的代码肯定在执行中
标签: asp.net-mvc-4 asp.net-mvc-routing