Hi,
In my MVC application I used a class SessionTimeoutAttribute for handling session timeout. This attribute I used in all the controller. Hence when the session expires, it’s getting redirected to login page. It’s working as expected.attaching/forums/uploadfile/cb8dbf/01042023172233PM/cls.txt the code which I have used in the filter class
But now I need to show a popup message which should show the message “Your session got expired. Please login again” and after clicking on the ok button on the popup, it should redirect to login page. Can someone please help me to fix the issue?
Thanks,
Hanusha
Uday DodiyaPosted Jan 9, 2023, 4:23 AM
To show a popup message when the session expires and redirect to the login page when the user clicks on the OK button, you can modify your
SessionTimeoutAttributeclass to check for the session expiration and show the popup using JavaScript.Here's an example of how you could do this:
This will show an alert message with the specified message and redirect to the login page when the OK button is clicked.
Rajesh GamiPosted Jan 5, 2023, 6:21 AM
Hi
Use the below links , definitely it will work for you
http://codemodus.blogspot.com/2016/06/aspnet-mvc-how-to-show-popup-warning.html
https://www.aspsnippets.com/Articles/Display-Session-Time-out-Warning-message-using-jQuery-in-ASPNet.aspx
https://www.codeproject.com/Questions/5301683/How-to-show-session-timeout-warning-message-in-ASP
https://haneefputtur.com/mvc-c-session-time-out-popup.html
Jignesh KumarPosted Jan 5, 2023, 3:51 AM
Hello,
Please refer this one,
https://www.c-sharpcorner.com/UploadFile/8911c4/session-time-out-warning-message-using-jquery-in-Asp-Net/
https://www.aspsnippets.com/Articles/Display-Session-Timeout-message-before-Session-expires-in-ASPNet.aspx
Pasang TamangPosted Jan 5, 2023, 3:38 AM
Hi,
You need to have a code that checks loggedin user or session in one of your controller. The methods that check session should be out of SessionTimeoutAttribute. Check below code for example
Regards,
Pasang