Ich habe folgendes Setup in meinem MVC 6 ASP.NET 5 Projekt:Ändern CookieAuthenticationOptions LoginPath OnRedirectToReturnUrl Ereignis
Startup.cs im Configure-Methode:
app.UseCookieAuthentication(options =>
{
options.AuthenticationScheme = "Cookie";
options.LoginPath = new PathString("/<TENANT>/account/signin/");
options.AccessDeniedPath = new PathString("/<TENANT>/account/unauthorised/");
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
options.Events = new CookieAuthenticationEvents
{
OnRedirectToReturnUrl = MyClass.RedirectToReturnUrlAsync
};
});
Events Klasse:
public static class MyClass
{
public static async Task RedirectToReturnUrlAsync(CookieRedirectContext context)
{
context.Options.LoginPath = new PathString("/<HERE I PLAN TO PUT LOGIC TO FIGURE OUT TENANT FROM CONTEXT>/account/signin");
}
}
Sagen wir, ein Benutzer geht zu der folgenden URL:
http://localhost/mycompany/securecontroller/secureaction
Ich möchte, dass die Cookie-Middleware der Benutzer zu umleiten:
http://localhost/mycompany/account/signin
Das Problem ist der Code „MyClass.RedirectToReturnUrlAsync“ nie getroffen wird, wenn ein Redirect RÜCKGABEURL geschieht, so kann ich nicht finden, die Gelegenheit zu ändern der LoginPath zur Laufzeit.
Ich vermute, ich habe etwas falsch in meinem Setup. Ist jemand jemals auf dieses Problem gestoßen?
Hooroo