STATIC VARIABLE IN ASP.NET

Chintoo Semi

Total Post:135

Points:947
Posted by  Chintoo Semi
 863  View(s)
Ratings:
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 ?)

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: static variable in asp.net

    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).

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!