I am using Angular + Asp.net Core 3.1 Web api which is integrated with OpenIDConnect using Cookie Authentication for the Single Sign on(OneLogin).I am not not using Identity. Angular is published on Asp.net core on IIS ( same domain). Cookie expiration is 7 hours as configured in Startup.cs. I am facing the issue where randomly(mostly bit of idle time), the following request anything to deal with HttpContext.User object takes lot of time to execute (like 42s) on production. Can anyone help?
[Route("isAuthenticated")]
public IActionResult IsAuthenticated()
{
return new ObjectResult(HttpContext.User.Identity.IsAuthenticated);
}
//or
var claimsPrincial = (ClaimsPrincipal)HttpContext.User;
//Startup.cs
.AddCookie("Cookies", options =>
{
options.ExpireTimeSpan = TimeSpan.FromMinutes(420);
options.Cookie.Name = Configuration.GetSection("CookieName").Value;
options.Cookie.Path = Configuration.GetSection("CookiePath").Value;
options.Cookie.SameSite = SameSiteMode.None;
})
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
According your description, we know that most of the (non-idle) time is normal.
In IIS, you can refer below pic to let your website always on.