我有一个用户报告说,当他们使用后退按钮返回一个网页时,他们会以另一个人的身份返回。似乎他们可能正在访问不同的用户个人资料。
以下是代码的重要部分:
//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;
}
我使用静态方法和 astatic WebProfile
因为我需要在static WebMethod
(ajax pageMethod
) 中使用配置文件对象。
- 这会导致不同用户“共享”配置文件对象吗?
- 我没有正确使用静态方法和对象吗?
我将WebProfile
对象更改为static
对象的原因是因为我需要访问 a 中的配置文件对象[WebMethod]
(从页面上的 javascript 调用)。
- 有没有办法在 a 中访问配置文件对象
[WebMethod]
? - 如果没有,我有什么选择?