I have developed a web site using Owin Security as middleware and using its Cookie Authentication. It is working fine on my local laptop (Windows 10) but when I deploy it to a Windows Server (2019), it is extremely slow. If I comment out the Owin Authentication (part of the codes listed below) from the Startup class, the response is fine but since this is not okay as I need to have authentication. Based on the log file content I program to generate, it looks like every time when I clicked on a link on a page, it delays about 30 seconds before my controller action kicks off - no matter what the controller action does, the delay is about the same. Anybody knows what causes the delay? I suspect it is the Owin Middleware but it is working fine on my laptop, which tells me something is wrong on the server too. Could you offer some hints as to where I should look into? Thanks!!
BTW - I also have a Web API web site on the same server and it also uses the OWIN Auth but the token authentication. The web api web site seems working fine and it is very responsive.
app.CreatePerOwinContext(ApplicationDbContext.Create);app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
System.Web.Helpers.AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);