簡體   English   中英

Page_Load中的ViewState為NULL,但不回發

[英]ViewState is NULL in Page_Load but not postback

在公司托管的高訪問量網站上,我遇到了一個N​​ullReferenceException怪異的問題。 使用完整的堆棧跟蹤記錄異常,但是我無法重現它。

對於不同的用戶,該異常每天發生兩次,並且在下面的代碼塊中引發NullReferenceException:

protected void Page_Load(object sender, EventArgs e)
{
    ...

    if (!Page.IsPostBack)
    {
        ...
        this.ViewState[StaticClass.StaticStringProperty] = StaticClass.StaticIntProperty; // this is the line the exception occurs on
        ...
    }
}

我唯一能想到的是,如果ViewState為NULL,則會拋出NullReferenceException,但是我從不知道,也找不到任何原因,導致在非回發的Page_Load中出現這種情況。

StaticStringPropertyStaticIntProperty都是StaticClass初始化靜態屬性。

StaticStringProperty定義為:

public const string StaticStringProperty = "IdFromClient";

有誰知道這是怎么發生的,或者其他任何原因會導致在上一行拋出NullReferenceException?

編輯

根據要求,錯誤的完整堆棧跟蹤如下。 第54行是我上面突出顯示的行。

at MyCompany.MyApplication.Appliance.Page_Load(Object sender, EventArgs e) in C:\Documents and  Settings\shellama\My Documents\MyApplication\Appliance.aspx.cs:line 54
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at MyCompany.MyApplication.PageBase.OnLoad(EventArgs e) in C:\Documents and Settings\shellama\My Documents\MyApplication\App_Code\PageBase.cs:line 58
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

我唯一能說的(最近我也有類似情況)是StaticClass.StaticStringProperty為NULL。 但是話又說回來,您一定已經注意了這一點。 我想不出別的東西。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM