I'm using Azure Active Directory application which contains user data and credentials. I access ASP .NET MVC 5 application with this credentials using Microsoft.Azure.ActiveDirectory.GraphClient library. After long inactivity, about 20 minutes, and clicking some link I got plain Server Runtime Error and cannot refresh page and login again. Only clearing cookies works.
What I tried:
- handle this error with customErrors - doesn't seem to work
- catching it in:
protected void Application_Error(object sender, EventArgs e)
{
var error = Server.GetLastError();
var cryptoEx = error as CryptographicException;
if (cryptoEx != null)
{
FederatedAuthentication.WSFederationAuthenticationModule.SignOut();
Server.ClearError();
HttpContext.Current.Response.Redirect("~/");
}
}
as described here: Federated Authentication on Azure
- problem does not exist while I'm using debugger and local machine, only on production - does it depend on IIS config?
- may I change sessionTimeout of Azure AD cookies not to wait 20 minutes every time?
- should I use 'static' machine key - not generated every time by Azure AD?