2011-05-18 19 views
0

在其中一個表單上發生錯誤,我可以編輯表單並單擊更新按鈕,當我第一次訪問該頁面並且一切正常時,但是如果我訪問該頁面並等待大約2 - 5分鐘,然後嘗試編輯表格並單擊更新按鈕,我出現此錯誤;'/'應用程序中的服務器錯誤

它看起來是會話ID的問題,我認爲這可能是超時問題,但我不知道。

任何建議將理解:

Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 80: protected void imgUpdateDetails_Click(object sender, EventArgs e)
Line 81: {
Line 82: SessionManager.CurrentBusinessClubMember.BCMListingDetails.BusinessClubMemberID = SessionManager.CurrentBusinessClubMember.ID;
Line 83: SessionManager.CurrentBusinessClubMember.BCMListingDetails.Address1 = editaddressline1.Value;
Line 84: SessionManager.CurrentBusinessClubMember.BCMListingDetails.Address2 = editaddressline2.Value;

Source File: d:Sitesdemelzabusinessclub.co.ukpublic_htmlWebsiteListingDetails.aspx.cs Line: 82

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] DemelzaBusinessClubSite_ListingDetails.imgUpdateDetails_Click(Object sender, EventArgs e) in d:Sitesdemelzabusin/essclub.co.ukpublic_htmlWebsiteListingDetails.aspx.cs:82
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Version Information: Microsoft .NET
Framework Version:2.0.50727.5444;
ASP.NET Version:2.0.50727.5420

+0

調試您的代碼並查看會話ID的值。另外,如果你可以避免使用Session,請這樣做。 – ZippyV 2011-05-18 09:32:28

回答

0

在你的方法

imgUpdateDetails_Click 

您有規定

SessionManager.CurrentBusinessClubMember.BCMListingDetails.Address2 = editaddressline2.Value; 

的錯誤指示以下的一個尚未被使用之前實例化的線。

SessionManager 
SessionManager.CurrentBusinessClubMember 
SessionManager.CurrentBusinessClubMember.BCMListingDetails 
editaddressline2 

除非您將這些對象存儲在會話中的某個位置,並在每個回帖中將它們拉出來,否則它們將爲空!

0

看起來gDetails是從您的堆棧跟蹤空,和/或SessionManager或SessionManager.CurrentBusinessClubMember。

/應用程序意味着您的應用程序正在您的服務器的根目錄中運行。

0

82行上的東西是null,即它沒有被設置爲一個值。 嘗試在第82行放置一個斷點並調試應用程序。然後檢查每個對象以查看哪些爲空。

相關問題