I am currently working on a project in written in ASP.NET MVC and I am struggling with this error for a few days now. Below is the scenario.
SCENARIO : This project uses T4MVC plugin by the way
Any ideas what's happening here?
UPDATE:
Code for the login. This is for the login form posting. It redirects to /Administration controller with an Index() action method.
public virtual ActionResult Index(LoginFormInput loginFormInput, string returnUrl)
{
if (!ModelState.IsValid)
{
return this.View();
}
if (!FormsAuthentication.Authenticate(loginFormInput.Username, loginFormInput.Password))
{
ModelState.AddModelError("login", BridgeDirect.Properties.Common.LoginFailure);
return this.View();
}
FormsAuthentication.SetAuthCookie(loginFormInput.Username, loginFormInput.RememberMe);
if (!string.IsNullOrEmpty(returnUrl))
{
return this.Redirect(returnUrl);
}
else
{
return this.RedirectToAction(MVC.Login.Index());
}
}
在验证用户的控制器方法中,如果成功,则返回RedirectToAction(“ Index”,“ Controller”)
Magic happens in the Account Controller (i guess you are using ASP.NET individual user accounts)
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
if (!ModelState.IsValid)
{
return View(model);
}
// This doesn't count login failures towards account lockout
// To enable password failures to trigger account lockout, change to shouldLockout: true
var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
switch (result)
{
// AFTER A SUCCESSFULL LOGIN THIS REDIRECTS THE USER TO THE
// PREVIOUS PAGE
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Invalid login attempt.");
return View(model);
}
}
Change this
return this.RedirectToAction(MVC.Login.Index());
To this
return RedirectToAction("Index","TheIndexMethodController");
Which if I'm guessing will be some HomeController, so like below:
return RedirectToAction("Index","Home");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.