Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Sys.WebForms.PageRequestManagerServerErrorException: 在伺服器上處理請求時出現未知錯誤。伺服器返回的狀態代碼為: 500
這個錯誤可能原因不止一個,我的錯誤原因是頁面上出現了編譯系統認為危險的字元(在<textarea>中出寫了"<div>")。這個“<div>”我這裡是不需要的,因此我的解決辦法是去掉了這個“<div>”字串。
而如果需要的話,可以在頁首加入 ValidateRequest="false",使其不校正危險字串
如下:
<%@ Page Language="C#" ..... ValidateRequest="false" %>
其他網上查到的解決辦法:
1,
顯示詳細的錯誤資訊的方法:
在 ScriptManager 內添加 EnablePartialRendering="false", 會顯示更加詳細的錯誤資訊。
如下:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false"/>
一般的原因都是頁面存在潛在的危險字元 在 頁首加入 ValidateRequest="false"
如下:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/CompanyManage.master" AutoEventWireup="true" CodeFile="CompanyIntroEdit.aspx.cs" Inherits="CompanyIntroEdit" Title="Untitled Page" ValidateRequest="false" %>
2,
在Web.Config
<system.web>
<pages enableEventValidation="false"/>
</system.web>
這個方法對於我當時的問題沒有效果,暫時還不知道是什麼情況用的。
3,
從。。。。中檢測到有潛在危險的 Request.Form 值。 也就是我當時的問題
解決辦法:
<!--在頁首加這一句,就不會提示:從用戶端檢測到有潛在危險的Request.Form 值 -->
如下:
<%@ Page Language="C#" ..... ValidateRequest="false" %>
也可以在webconfig加上
<pages validateRequest="false"/>