Home > DeveloperSection > Forums > static variable in asp.net
Chintoo Semi

Total Post:135

Points:947
Posted on    November-20-2014 10:24 PM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 530  View(s)
Rate this:

I would like to have kind of static variable but isolated for each user session so is static variable in asp.net common to all users ?

 

If yes is there an easy to emulate what I want without using user session explicitly ? I cannot use Viewstate either as I'm using MVC (or am I mistaken ?)



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    November-20-2014 11:41 PM

Hi Chintoo, 

A static variable will be common for all sessions yes.

If you want to keep per-user-session data you have three options:

·        Use built in Session handling.

·        Set a cookie.

·        Pass the data as a hidden form field that is posted to the server (works for places where you have a form anyway).


Don't want to miss updates? Please click the below button!

Follow MindStick