C# UpdatePanel 回发错误:Sys.WebForms.PageRequestManagerParserErrorException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9085593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 05:49:50  来源:igfitidea点击:

UpdatePanel Postback Error: Sys.WebForms.PageRequestManagerParserErrorException

c#asp.net.netajaxvisual-studio-2010

提问by Cade Roux

Already looked at this: Sys.WebForms.PageRequestManagerParserErrorException - what it is and how to avoid it

已经看过这个: Sys.WebForms.PageRequestManagerParserErrorException - 它是什么以及如何避免它

Problem is that it's only happening on my dev box. Two other developers are fine.

问题是它只发生在我的开发箱上。另外两个开发人员很好。

It's consistent and reproducible - I've tried deleting temporary internet files, deleted my obj and bin files and rebooting.

它是一致且可重现的 - 我尝试删除临时 Internet 文件,删除我的 obj 和 bin 文件并重新启动。

The response is clearly truncated when I look at it in the debugger when it hits the error.

当我在调试器中查看它时,当它遇到错误时,响应显然被截断了。

Where else do I need to check to clear/clean out?

我还需要检查哪里来清除/清理?

The error I'm seeing in the code is:

我在代码中看到的错误是:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near ' </tr>'.

Microsoft JScript 运行时错误:Sys.WebForms.PageRequestManagerParserErrorException:无法解析从服务器收到的消息。此错误的常见原因是通过调用 Response.Write()、响应过滤器、HttpModules 或启用服务器跟踪来修改响应。详细信息:在“ </tr>”附近解析错误 。

_endPostBack: function PageRequestManager$_endPostBack(error, executor, data) {
    if (this._request === executor.get_webRequest()) {
        this._processingRequest = false;
        this._additionalInput = null;
        this._request = null;
    }

    var eventArgs = new Sys.WebForms.EndRequestEventArgs(error, data ? data.dataItems : {}, executor);
    Sys.Observer.raiseEvent(this, "endRequest", eventArgs);
    if (error && !eventArgs.get_errorHandled()) {
        throw error; // THIS IS WHERE THE ERROR IS THROWN
    }
},

This is during an Ajax postback.

这是在 Ajax 回发期间。

  1. There are no Response.Write calls.

  2. I'm using Cassini/VS 2010 Development Server, how do I tell if there are filters?

  3. ditto

  4. Server trace is not enabled

  5. No calls to Server.Transfer

  1. 没有 Response.Write 调用。

  2. 我正在使用 Cassini/VS 2010 开发服务器,如何判断是否有过滤器?

  3. 同上

  4. 未启用服务器跟踪

  5. 没有调用 Server.Transfer

In firebug, I can see that the response to the POST is truncated. Problem happens in Firefox or IE, and whether I'm debugging in VS or not.

在萤火虫中,我可以看到对 POST 的响应被截断了。问题发生在 Firefox 或 IE 中,以及我是否在 VS 中调试。

The problem does go away if I switch to IIS Express in Visual Studio, and then it returns when I am back on the ASP.NET Development Server.

如果我在 Visual Studio 中切换到 IIS Express,问题就会消失,然后当我回到 ASP.NET 开发服务器时它会返回。

采纳答案by Aristos

After our talk, my idea was that maybe for some reason the cassini can not hold a big post back field, and a big one is the viewstate.

经过我们的谈话,我的想法是,也许由于某种原因卡西尼不能容纳一个大的后场,而一个大的就是viewstate。

So if the viewstate is a very big one maybe this is the problem.

因此,如果视图状态非常大,那么这可能就是问题所在。

A second case maybe if the viewstate contain characters that some time not pass by the router or some firewall and cut them as possible attach or virus.

第二种情况可能是,如果视图状态包含一段时间未通过路由器或某些防火墙的字符,并将它们作为可能的附件或病毒进行切割。

Possible solutions: To compress the viewstate, and/or to cut it in smaller parts.

可能的解决方案:压缩视图状态,和/或将其切割成更小的部分。

You can also download the latest developer edition version of Cassini with lot of improvements at http://cassinidev.codeplex.com/that maybe have fix this issue.

您还可以在http://cassinidev.codeplex.com/下载最新的 Cassini 开发者版,其中有很多改进 ,可能已经解决了这个问题。

回答by daniloquio

Are you using some kind of http module compression? It seems to cause problems very much like yours when using updatepanels. Please review this post.

你在使用某种 http 模块压缩吗?使用更新面板时,它似乎会导致与您非常相似的问题。请查看这篇文章

If you are not ussing compression, maybe another httpmodule relatederror is making you suffer. Try adding this to your webpage:

如果您没有使用压缩,也许另一个与 httpmodule 相关的错误让您受苦。尝试将其添加到您的网页:

enableEventValidation="false"

Maybe you could catch the exception with this kind of code:

也许你可以用这种代码捕获异常:

 protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
    {
        ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message+e.Exception.StackTrace ;
    }

<asp:ScriptManager ID="ScriptManager1" runat="server" 
            OnAsyncPostBackError="ScriptManager1_AsyncPostBackError">
</asp:ScriptManager> 

Sourcefor that last thing.

最后一件事的来源

回答by Reinaldo

I have seen this problem before with Cassini. I solved it by adding the following to the Web.config:

我以前在 Cassini 上见过这个问题。我通过将以下内容添加到 Web.config 来解决它:

<system.web>
  <httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </httpModules>
</system.web>

The entry above is for version 1.0. Make sure that the Versionand PublickKeyTokenattributes match the ASP.net Ajax version that you are using. Also you may want to disable event validation in your page:

上面的条目适用于版本 1.0。确保VersionPublickKeyToken属性与您使用的 ASP.net Ajax 版本匹配。此外,您可能希望在页面中禁用事件验证:

enableEventValidation="false"

Hope it helps!

希望能帮助到你!

回答by jayesh

Error:

错误:

Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

solution:

解决方案:

<add key="aspnet:MaxHttpCollectionKeys" value="100000"/ >

Add above key in app setting section.

在应用设置部分添加上面的键。