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:
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
我终于做了一个解决方法:我没有处理这个令人讨厌的异常,而是只是通过JavaScript调度的请求来保持会话,这些请求正在调用控制器并设置了一些Session["Value"]
I also handled this by making sure my pages refresh every 30 minutes.
This can be done in HTML by adding the meta tag
<meta http-equiv="refresh" content="1800">
It can also be done via Javascript
setInterval(function() {
window.location.reload();
}, 180000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.