Вопрос и ответы здесь, похоже, относятся к старым формам аутентификации.В более новых версиях MVC, например, MVC 5 (с Identity 2.0), вы должны сделать что-то подобное в Startup.Auth.cs
:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/account/login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ReturnUrlParameter = "redirect"
});
Важная часть, конечно, ReturnUrlParameter = "redirect"
(может быть чем угодно),Остальное может отличаться для вашего проекта.