我有一個會話變量,需要在具有許多webmethod函數的cs頁面上使用。如果我聲明如下,我並不總是得到最新的變量。有時它給了我最後一個之前存儲的變量。我究竟做錯了什麼?聲明一個將被許多WebMethod函數使用的靜態變量
public partial class uc_functions : MyBasePage
{
static string ucService = HttpContext.Current.Session["ucService"] as string;
....
[WebMethod] //1
[WebMethod] //2
[WebMethod] //3
您需要在每個webmethod中獲取此值,因爲其值可能已更改。 – Mairaj
這是否意味着我必須申報20次?這對我來說沒有意義....!或者也許就是這樣。 – Gloria
沒有聲明它只是一次,並在每個webmethod – Mairaj