Last post Jul 09, 2019 11:49 AM by AddWeb Solution
Jun 27, 2019 11:42 PM|JORGEMAL|LINK
I need to use one session variable in my ASP.NET MVC 5 project and keep the default timeout.
What is the value of an expired session variable?
If such a session variable has expired and I need it again, is it enough to re-define?
Is the code example below correct?
What is the correct code to detect if the session variable expired and, if so, re-define it again.
if (Session["var"] has expired)
Session["var"] = some value;
I will very much appreciate your feedback.
Jun 28, 2019 02:23 AM|Wei Zhang|LINK
According to your description, if the session value has expired , the value will be null. So ,you could use code as below:
if (Session["var"] == null )
Session["var"] = some value;}
If you want to redefine it , you could set somevalue as you want.
Jul 09, 2019 11:49 AM|AddWeb Solution|LINK
On page_load you can check any of them and carry out the appropriate action i.e. Response.Redirect. However you say in the Web.Config you can check when the authentication
cookie is gone, so can you not carry out an action on this?
Please Refer Below Link, Hope you will get as you want