public ActionResult LogOn(string returnUrl)
{
if (Request.IsAuthenticated)
{
return RedirectToAction(string.Empty, "home");
}
else
{
if (!string.IsNullOrWhiteSpace(returnUrl))
{
//http://localhost:666/en-us/account/logon?returnurl=%2fen-us%2fadminka
//..............
}
return View();
}
}
[HttpPost]
public ActionResult LogOn(LogOnViewModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (....)
{
//..............
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
return Redirect(returnUrl);
return RedirectToAction(string.Empty, "home");
}
else
{
//..............
}
}
return View(model);
}
在
HttpPost LogOn
中,returnUrl
始终等于null,即使在HttpGet LogOn
中它不为null。为什么?我该如何解决?
LogOn(string returnUrl)
和 URL 中都有?returnurl=
参数。 - Alexandre