I use CookieAuthentication in my application with owin and set the redirect URL to OnApplyRedirectas the following code:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromDays(30),
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/account/sign-in"),
ReturnUrlParameter = "returnTo",
CookieName = "BIR",
Provider = new CookieAuthenticationProvider()
{
OnValidateIdentity = SmObjectFactory.Container.GetInstance<IAppUserManager>().OnValidateIdentity(),
OnApplyRedirect = c =>
{
if (!c.Request.IsAjaxCall())
{
c.Response.Redirect(c.RedirectUri);
}
}
}
});
my problem is the value c.RedirectUri, I set a breakpoint and track my code after that. I understand what OnApplyRedirect is called server time .
The first call RedirectUrihas:
http://localhost:7537/account/sign-in?returnTo=%2Fadmin-panel
The second call RedirectUrihas:
http://localhost:7537/account/sign-in?returnTo=%2Faccount%2Fsign-in%3FreturnTo%3D%252Fadmin-panel
And further...
In pre call old url add new url. I try to solve this problem, search and research on another and current site, but I can not find the answer, why does it OnApplyRedirectcall several times?
Configurationin class Startup.csCalled only once. other details: