How do I find out if the session has expired?

2

I need to find out when the session expires, in ASP.Net MVC, so I can show a modal and redirect.

How can I do this?

Is there anything in the% w /% of what I can use?

    
asked by anonymous 19.08.2014 / 23:47

2 answers

1

To verify that the session is still valid, just check the property: HttpContext.Current.User.Identity.IsAuthenticated .

And make the code you want according to the result. (modal, redirection)

I recommend that you see the official documentation for more details and examples.

    
20.08.2014 / 00:21
0

Since the server does not have a persistent connection to the client, you can create a javascript timer with the same session duration on your server.

When you reach this time you display the modal and when closing the modal you can redirect it to the login screen. It does not matter if you spent a few seconds or more, as long as the session on the server does not exist anymore, it will be redirected if you have done the correct validations ...

In this case you have nothing to worry about, but if you still want to move it, when you reach the time you can use a call in ajax (post preference) in a simple action that deletes the session.

    
20.08.2014 / 01:48