Alex Rivera | Logout

Static variable in asp.net page

Asked 2011-03-07T09:01:47.523
18

I am having one doubt regarding the use of static variable in Asp.net pages.

I am having one page say UserDetails.aspx. In this page, I have one static variable to store some data specific to a user. So, will this variable be shared across multiple user or a separate variable will be created for each user?

  public partial class UserDetails : System.Web.UI.Page
    {
       static int numberOfReviews=0;
       protected void Page_Load(object sender, EventArgs e)
         {
            numberOfReviews= GetReviews();
         }
    }

Here, will numberOfReviews be specific to each user or will be shared?

numberOfReviews

Edit
Report

1 Answer

0

usually to do this a database is used

Data Table
userId | UserViews

Also you can use static variable as u are saying in that case you have to store data in Application State, problem with that is, ur whole data will be resett whenever ur will re-start.

answered 2011-03-07T09:07:00.060

Your Answer