これが私のログインコントローラーです
// 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()
%>
ログイン後、私はこのURLにいます:
http://localhost:8085/MobileApprover/Login/Login?ReturnUrl=%2fMobileApprover%2f&AspxAutoDetectCookieSupport=1#/MobileApprover/Login/Login?ReturnUrl=/MobileApprover/
このURLhttp:localhost:8085 / MobileApproverにアクセスしたいのは、そのURLを入力すると(デバッグ時)、ホームコントローラーがビューを正しく表示するためです。
この時点で私は何を間違っていますか?この問題はリターンURLとその処理方法に関連していると思いますが、
return Redirect(ReturnURL)
しかし、それも機能しません。