如何修复错误:从服务器收到的消息无法解析 [英] How to fix error: The message received from the server could not be parsed

查看:851
本文介绍了如何修复错误:从服务器收到的消息无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用AJAX SharePoint解决方案。触发此按钮是一个更新面板内。



其中一个,我们做的是生成一个MS Word文档的事情,就是然后在客户端上打开,使得它。可打印

这将文档发送到客户端的代码如下所示:

 无效OpenFileInWord(字节[]数据)
{
Response.Clear();
Response.AddHeader(内容类型,应用程序/ msword);
Response.BinaryWrite(数据);
Response.Flush();
到Response.End();
}

这是我们得到的错误是:



消息:Sys.WebForms.PageRequestManagerParserErrorException:从服务器收到的消息无法解析。此错误的常见的原因是当响应由呼叫修改为回复于(),响应滤波器,的HttpModules或服务器跟踪被使能。
详细:错误解析附近'?< MSO的申请PR



我们可以先保存在SharePoint中的文件,然后从SharePoint打开它,但我们不希望这样做。


解决方案

这导致该代码得到执行,必须在行动是回发事件,而不是一个AJAX调用。



这是由于AJAX请求的处理方式的性质。


We have a Sharepoint solution that uses AJAX. The button that triggers this is inside an update panel.

One of the things that we do is generate a MS Word document, that is then opened on the client so that it can be printed.

The code that sends the document to the client looks like this:

    void OpenFileInWord(byte[] data)
    {
        Response.Clear();
        Response.AddHeader("Content-Type", "application/msword");
        Response.BinaryWrite(data);
        Response.Flush();
        Response.End();
    }

The error that we are getting is:

Message: 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 '<?mso-application pr'.

We could save the document in Sharepoint first, and then open it from Sharepoint, but we would prefer not to do this.

解决方案

The action that causes this code to execute MUST be a postback event, and not an AJAX call.

This is due to the nature of the way AJAX requests are processed.

这篇关于如何修复错误:从服务器收到的消息无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆