导出呈现的HTML页面到Word不工作在IE [英] Exporting rendered HTML page to Word is not working in IE

查看:198
本文介绍了导出呈现的HTML页面到Word不工作在IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我出口到MS Word和下载点击一个按钮呈现的HTML页面。

下面是按钮点击code片段。

 `Me.EnableViewState =假
    Response.ContentType =应用程序/ vnd.ms字
    Response.AddHeader(内容处置,附件;文件名= XXXXXXX.doc)
    将Response.Buffer = TRUE
    Response.BufferOutput = TRUE;

该功能很完善在Firefox和放大器; IE浏览器,当我检查在系统测试环境(本地)。然而,当它被转移到托管服务器(生产环境)功能不能在IE工作,但仍然在Firefox完美的工作。

我不知道在哪里可以检查的确切问题。难道是一个高速缓存相关的问题?

在IE中它只是不打开下载窗口,当呈现的HTML内容类型发生变化,响应流被刷新,我们将获得。无异常。

我收到了以下响应头:

  HTTP / 1.0 200 OK
缓存控制:私人
内容长度:15189
内容类型:应用程序/ vnd.ms字;
字符集= utf-8的服务器:Microsoft-IIS / 7.5的X ASPNET-版本:2.0.50727
内容处置:附件;文件名= NewAccountForm.doc的X技术,通过:ASP.NET
日期:星期五,2011 3月18日10时18分07秒格林尼治标准​​时间的X缓存:错过网关的X缓存查找:错过网关:808通过:1.0网关(鱿鱼/ 3.0.STABLE10) - 代理连接:保持活动


解决方案

是您的托管环境中添加HTTP头? IIS可以很容易地被配置为添加页眉的那被搞乱了,你想送什么。这其实很常见,可能是这个问题。您需要确定这是肯定的,所以这里的调查建议:

尝试使用 WebClient的类,看看响应

编辑 - 更新

我只注意到 - 你记得把

  Response.Clear();

添加头前?它可能不是托管环境的。然而,由于它工作在本地,而不是在您的托管环境,assming它是在同一code,它仍然看起来对我喜欢的事是关于托管环境不同,最合乎逻辑的选择将是头。

I have a rendered HTML page that I am exporting to MS Word and downloading on a button click.

Here is the code snippet in the button click.

` Me.EnableViewState = False
    Response.ContentType = "application/vnd.ms-word"
    Response.AddHeader("Content-Disposition", "attachments;filename=XXXXXXX.doc")
    Response.Buffer = True
    Response.BufferOutput = True`

The functionality works perfectly well in Firefox & IE when I checked in system testing environment (locally). However when it was moved on to the hosting server (production environment) the functionality is not working in IE but is still working perfectly in Firefox.

I am not sure on where to check for the exact issue. Could it be a caching related problem?

In IE it is just not opening the download window which we will obtain when the rendered HTML content type is changed and the response stream is flushed. No exception is thrown.

I received the following response header:

HTTP/1.0 200 OK
Cache-Control: private 
Content-Length: 15189 
Content-Type: application/vnd.ms-word; 
charset=utf-8 Server: Microsoft-IIS/7.5 X-AspNet-Version: 2.0.50727 
Content-Disposition: attachments;filename=NewAccountForm.doc X-Powered-By: ASP.NET 
Date: Fri, 18 Mar 2011 10:18:07 GMT X-Cache: MISS from Gateway X-Cache-Lookup: MISS from Gateway:808 Via: 1.0 Gateway (squid/3.0.STABLE10) Proxy-Connection: keep-alive

解决方案

Is your hosted environment adding http headers? IIS could easily be configured to add headers that are messing up what you want to send out. It's actually quite common, and could be the issue. You'll need to determine this for sure, so here's a suggestion for investigating:

Try using a WebClient class and look at the Response headers.

Edit - updated

I just noticed - did you remember to put

Response.Clear();

before adding headers? It may not be the hosting environment at all. However, given that it works locally and not at your hosting environment, and assming that it is the same code, it still looks to me like something is different about the hosted environment, and the most logical option would be the headers.

这篇关于导出呈现的HTML页面到Word不工作在IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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