We are using datatables with ASP.Net MVC and identity framework. I have set the authentication timeout to 1 minute using the code below:
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
...
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = System.TimeSpan.FromMinutes(1),
Provider = new CookieAuthenticationProvider
{
...
});
I then login and go to a page with a datatable and wait for the timeout. An error occurs if the timeout expires and the datatable tries to hit the server. The datatable works by making an ajax request to the server and this is where the error comes from.
The error is a JavaScript error:
DataTables warning: table id=DataTables_Table_0 - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
I need to handle this gracefully and redirect the user to the login page.
Can anyone help please?
.NET has a built in Time Out Exception:
More: https://msdn.microsoft.com/en-us/library/system.timeoutexception(v=vs.110).aspx
EDIT:
For an AJAX time out, maybe this thread would help?
Handling session timeout in ajax calls