Clear specific controller session

Posted by Gunam under ASP.NET MVC on 8/20/2014 | Points: 10 | Views : 543 | Status : [Member] | Replies : 2
Hi,

In my project I'm using session to maintain some complex type data. I want to clear that session if that specified controller has not been hit for a specified amount of time , need to clear that specific session only that have been used in that controller not all the entire user session .

Let say,

BusinessController has some ActionMethods like Test1, Test2 .

The ActionMethod Test1 has some Session like Session["MyData"], Session["ListOfBusiness"] .
The ActionMethod Test2 has some Session like Session["MyData"], Session["ListOfBusiness"] .

I need to clear the session Session["MyData"], Session["ListOfBusiness"] only if BusinessController has not been hit for some time.

Guna


Responses

Posted by: kgovindarao523-21772 on: 8/21/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,
Try like this.
Session.Remove("MyData");
Session.Remove("ListOfBusiness");


Thank you,
Govind

Gunam, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gunam on: 8/22/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for the response. Yes of-course we have to use
Session.Remove
But in my case I want to track that controller then only need to clear those session if only that the controller has not been hit for some time . Let say for 5 mins.

Guna

Gunam, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response