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

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

问题描述

我们有一个使用 AJAX 的 Sharepoint 解决方案.触发此操作的按钮位于更新面板内.

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

我们所做的其中一件事是生成一个 MS Word 文档,然后在客户端上打开该文档以便进行打印.

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();
    }

我们得到的错误是:

消息:Sys.WebForms.PageRequestManagerParserErrorException:无法解析从服务器收到的消息.此错误的常见原因是通过调用 Response.Write()、响应过滤器、HttpModules 或启用服务器跟踪来修改响应.详细信息:在<?mso-application pr"附近解析错误.

我们可以先将文档保存在 Sharepoint 中,然后从 Sharepoint 中打开它,但我们不希望这样做.

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

推荐答案

导致此代码执行的操作必须是回发事件,而不是 AJAX 调用.

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

这是由于 AJAX 请求处理方式的性质所致.

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

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

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