2012-05-25 50 views
5

我在按鈕單擊時收到以下異常,對於頁面加載時綁定超過500條gridview記錄的asp頁面。最大請求長度超過回發異常

我的頁面沒有任何上傳控件。它包含一個文本框,按鈕和gridview。有沒有人知道爲什麼會發生這種情況。

異常說明:

Maximum request length exceeded. 
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. 

回答

16

回傳發回每個控件的視圖狀態 - 如果你有一個龐大的數據網格,然後在瀏覽器轉播到服務器,這就是爲什麼你所得到的例外。

你有兩個選項:

  1. 在你的GridView設置EnableViewState="false"如果你不需要視圖狀態,所以它不是那麼臃腫和回傳是一個合理的規模,
  2. 增加最大請求大小在web.config如下圖所示:

    <configuration> 
        <system.web> 
         <httpRuntime maxRequestLength="32768" /> 
        </system.web> 
    </configuration> 
    

希望這有助於

+1

這是視圖狀態。爲了使它工作,我做了假。非常感謝。 – NewBie

相關問題