这是我的登录控制器
// POST: /Account/Login
[AllowAnonymous]
[HttpPost]
public ActionResult Login(LoginModel model, string ReturnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(ReturnUrl))
{
return RedirectToAction("Index", "Home");
}
else
{
return RedirectToAction("Login", "Login");
}
}
else
{
ModelState.AddModelError("invalid", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
当我开始调试时,这是登录页面上的 url:
http://localhost:8085/MobileApprover/Login/Login?ReturnUrl=%2fMobileApprover%2f&AspxAutoDetectCookieSupport=1
这是我用来发布的表格
<form class="form" action="/MobileApprover/Login/Login?ReturnUrl=<%=Request.QueryString["ReturnUrl"]%>" method="post">
<input type="text" class="span12" name="UserName" placeholder="User Name" />
<input type="password" class="span12" name="Password" class="" placeholder="Password"/>
<label class="checkbox">
<input type="checkbox" name="RememberMe" class="" />
Remember Me?
</label>
<button type="submit"">Login</button>
<%:
Html.ValidationSummary()
%>
登录后我在这个网址:
http://localhost:8085/MobileApprover/Login/Login?ReturnUrl=%2fMobileApprover%2f&AspxAutoDetectCookieSupport=1#/MobileApprover/Login/Login?ReturnUrl=/MobileApprover/
我想在这个 url http:localhost:8085/MobileApprover 因为当我输入那个 url(调试时)家庭控制器正确地显示视图。
我在这一点上做错了什么?我相信这个问题与返回 url 以及我如何处理它有关,但我已经尝试过
return Redirect(ReturnURL)
但这也不起作用。