Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 55821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:26:15+00:00 2026-05-10T17:26:15+00:00

I have a user reporting that when they use the back button to return

  • 0

I have a user reporting that when they use the back button to return to a web page that they come back as a different person. It seems like they may be accessing a different users profile.

Here are the important parts of the code:

//here's the code on the web page  public static WebProfile p = null;  protected void Page_Load(object sender, EventArgs e) {     p = ProfileController.GetWebProfile();     if (!this.IsPostBack)     {          PopulateForm();     }        }  //here's the code in the 'ProfileController' (probably misnamed) public static WebProfile GetWebProfile() {     //get shopperID from cookie     string mscsShopperID = GetShopperID();     string userName = new tpw.Shopper(Shopper.Columns.ShopperId,        mscsShopperID).Email;     p = WebProfile.GetProfile(userName);      return p; } 

I’m using static methods and a static WebProfile because I need to use the profile object in a static WebMethod (ajax pageMethod).

  • Could this lead to the profile object being ‘shared’ by different users?
  • Am I not using static methods and objects correctly?

The reason I changed WebProfile object to a static object was because I need to access the profile object within a [WebMethod] (called from javascript on the page).

  • Is there a way to access a profile object within a [WebMethod]?
  • If not, what choices do I have?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:26:15+00:00Added an answer on May 10, 2026 at 5:26 pm

    A static object is shared across all instances of an application so if you alter the value of a static object, that alteration will be reflected across all instances of the application which access that object. Therefore if your web profile is reassigned by another thread (i.e. a second user visiting a page) inbetween you setting it for the current user, it will contain information different to what you expect.

    To get around this your code should look something like:

    public WebProfile p = null;  protected void Page_Load(object sender, EventArgs e) {     p = ProfileController.GetWebProfile();     if (!this.IsPostBack)     {          PopulateForm();     }        }  public static WebProfile GetWebProfile() {     //get shopperID from cookie     string mscsShopperID = GetShopperID();     string userName = new tpw.Shopper(Shopper.Columns.ShopperId,        mscsShopperID).Email;     return WebProfile.GetProfile(userName);  } 

    Note that the static object has not been set and the returned value should be assigned to a NON STATIC instance of the web profile class in your calling method.

    Another option is to LOCK your static variable for the whole time it is in use but this will lead to severe degradation in performance as the lock will block any other requests for the resource until the current locking thread is completed – not a good thing in a web app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer pthread_cond_timedwait takes an absolute time, not a relative time. You… May 11, 2026 at 9:46 am
  • added an answer What you are describing is commonly known as Derived Object… May 11, 2026 at 9:46 am
  • added an answer if your services are stateless/sessionless then it's a good practice… May 11, 2026 at 9:46 am

Related Questions

I have a user reporting that when they use the back button to return
I have a user that want to be able to select a textbox and
I have a user interface in .net which needs to receive data from a
I have a user script that would be much more useful if it could
I have a user control in a repeater that I need to pass data
I have a User class which may or may not have an associated Department.
I have a user control that is pretty basic. It contains several TextBox controls,
I have a user control ( gallery.ascx ) and I want to use the
I have a user table in my mysql database that has a password column.
I have a user control where the XAML of the control can bind to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.