我有一个Asp.net MVC程序,它无法重定向到root" /"登录成功后。它有效。 登录网址: http://localhost:8080/Account/Login?ReturnUrl=%2f
登录后,它应为http://localhost:8080/。
但它显示http://localhost:8080/Account/Login?ReturnUrl=/
如果它显示此URL,则布局页面将继续使用LoginLayout。
如果我手动输入根URL - http://localhost:8080/,则会正确显示。
这是我的控制器代码:
[HttpGet]
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
LoginViewModel model = new LoginViewModel();
return View(model);
}
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
if (ModelState.IsValid)
{
var user = await UserManager.FindAsync(model.UserName, model.Password);
if (user != null)
{
await SignInAsync(user, model.RememberMe);
return RedirectToLocal(returnUrl);
}
else
{
ModelState.AddModelError("Error", "Invalid username or password.");
}
}
return View(model);
}
查看代码:
@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post))
由于 威尔逊
答案 0 :(得分:0)
通过再次删除和添加所有js和css文件来解决问题。问题是文件版本控制。
再次感谢你。