我一直使用以下两位代码(用于工作)来捕获 Ajax asyncPostBackError。
<asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" />
和
protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
{
ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message;
}
但是现在,即使在此事件处理函数中捕获了未处理的异常并AsyncPostBackErrorMessage设置了异常消息,无论异常消息是什么,我总是在页面中的警告框中收到相同的错误报告,说:
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message recieved from the server could not be parsed. Common causes for this error are when the response is modified by calls to the Respnse.Write() ....
asyncPostBack如果您有未处理的异常并且您没有连接Scriptmanger's asyncPostBackError事件处理程序方法,则该错误与您将得到的错误相同。
无论我做什么,我都会得到同样的错误。什么会导致这种情况?