2011-07-05 3 views
0

dropdownlist의 포스트 백에서이 예외가 발생합니다. 참고 : Dropdownlist는 값 유형 및 해당 usercontrol로 BigInt와 바인딩됩니다. 나는이 예외 얻고 난 드롭 다운리스트에서 값을 선택할 때 :오류 :이 페이지에 대한 상태 정보가 유효하지 않아 손상되었을 수 있습니다.

The state information is invalid for this page and might be corrupted. 
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.Web.HttpException: The state information is invalid for this page and might be corrupted. 

Source Error: 

[No relevant source lines] 


Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\074f73f4\bcce5747\App_Web_j32tj0nd.0.cs Line: 0 

Stack Trace: 

[FormatException: Input string was not in a correct format.] 
    System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +9594283 
    System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119 
    System.Convert.ToInt32(String value, IFormatProvider provider) +48 
    System.Web.UI.Page.get_RequestViewStateString() +245 

[ViewStateException: Invalid viewstate. 
    Client IP: ::1 
    Port: 2479 
    Referer: http://localhost:89//home.aspx?catid=8 
    Path: /home.aspx 
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.18) Gecko/20110614 AskTbPTV2/3.12.2.16749 Firefox/3.6.18 GTB7.1 
    ViewState: ] 

[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.] 
    System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +198 
    System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState) +14 
    System.Web.UI.Page.get_RequestViewStateString() +567 
    System.Web.UI.HiddenFieldPageStatePersister.Load() +241 
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106 
    System.Web.UI.Page.LoadAllState() +43 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431 
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253 
    System.Web.UI.Page.ProcessRequest() +78 
    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 
    System.Web.UI.Page.ProcessRequest(HttpContext context) +49 
    ASP.home_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\074f73f4\bcce5747\App_Web_j32tj0nd.0.cs:0 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 

내가 구글 수행과 같은 것들을 많이 시도 :

<pages maxPageStateFieldLength="40" 

ValidateRequest="false" 

: webconfig에 을 하지만 해결책은 없습니다.

전문가에게 제게 해결책을 제공해주세요. 지난 몇 시간 동안이 문제에 직면하고 있습니다. 이전에는 문제가 없었습니다.

편집 : 참고 : 나는 지금 테스트를 통해 UC가 다른 페이지 "테스트 페이지"에서 정상적으로 작동하는 것으로 나타났습니다. 나는 그것이 어떤 것으로 상충되어야한다고 생각합니다 ... 제발 제안하십시오 ..

답변

0

마침내 나는 문제를 해결했지만 여전히 그것의 이유를 이해할 수 없습니다. 내 페이지가 포함되었다 : 내 페이지에서

public bool ShowTabbedFlash 
     { 
      get { return showTabbedFlash; } 
      set { showTabbedFlash = value; } 
     } 

protected void Page_Load(object sender, EventArgs e) 
     { 
      if (ShowTabbedFlash) 
      { 
       UserControls.TabbedFlash tf = (UserControls.TabbedFlash)Page.LoadControl("UserControls/TabbedFlash.ascx"); 
       Phtabbedflash.Controls.Add(tf); 
      } 
     } 

:

<%@ MasterType VirtualPath="~/Main.Master" %> 

코드에 내가 설정 한 값

내 Masterpage이 속성이 포함

나는 같은 문제를 해결 마스터 페이지 속성 :

private void ShowTabbedFlash() 
     { 
      Master.ShowTabbedFlash = true; 
     } 

지금은 masterpage의 재산

// Master.ShowTabbedFlash = true; 

하고 시작 .. 잘 작동

전문가의 값을 변경의 코드를 주석 때 나에게 지식을 제공하시기 바랍니다 이유 때문에 MasterPage의 속성 그 해프닝?

+0

설명에 대한 내 대답을 참조하십시오. – VinayC

2

귀하의 문제는 페이지/컨트롤 라이프 사이클과 관련되어 있습니다. 포스트 트리에서 컨트롤 트리를 수정하거나 동적으로 컨트롤을로드 할 때 발생합니다. ASP.NET에서는 동일한 컨트롤 트리가 존재해야만 그렇지 않으면 뷰 상태를 올바르게로드 할 수 없으며 오류가 발생합니다.

그래서 당신을 위해 범인 코드 이하 :

if (ShowTabbedFlash) 
{ 
    UserControls.TabbedFlash tf = UserControls.TabbedFlash)Page.LoadControl("UserControls/TabbedFlash.ascx"); 
    Phtabbedflash.Controls.Add(tf); 
} 

일반적으로 제어 ID를 일치에 의해 제어 트리 매칭 작업 -이 게시물에 변경됩니다 경우 - ID를 제공하지 않음으로써는, ASP.NET은 제어 ID를 생성합니다 그런 다음 ASP.NET 런타임은 뷰 상태와 오류를 복원하는 동안 특정 ID에 대해 잘못된 컨트롤 유형을 발견합니다. 특정 ID를 사용자 정의 컨트롤에 부여하면 작동합니다 (비슷한 로직이 페이지의 다른 부분이나 사용자 정의 컨트롤 내에서 동적으로로드 된 컨트롤에 적용됩니다). 예 :

if (ShowTabbedFlash) 
{ 
     UserControls.TabbedFlash tf = UserControls.TabbedFlash)Page.LoadControl("UserControls/TabbedFlash.ascx"); 
     tf.ID = "SomeUniqueID"; 
     Phtabbedflash.Controls.Add(tf); 
} 
+0

그게 나를 위해 작동하지 않습니다 : ( –

+0

master에서 page_init 관련 코드를 이동 시도 할 수 있습니다. – VinayC

+0

때문에 여전히 문제가 .. –

관련 문제