Word打开时,已下载的文档已消失 [英] Downloaded document has disappeared by the time Word has opened

查看:75
本文介绍了Word打开时,已下载的文档已消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经实现了允许用户使用以下代码从IIS服务器下载文档(任何

文档类型)的功能:


Response.Clear()

Response.ContentType =" application / x-msdownload"

Response.AddHeader(" Content-Disposition"," attachment; filename ="&

System.IO.Path.GetFileName(FilePath))

Response.AddHeader(" Content-Length",File.Length.ToString() )

Response.WriteFile(FilePath)

Response.End()


当回复此响应时,IE会提示用户是否要打开,保存或取消下载
。如果他们将

文档保存到本地硬盘驱动器然后打开它,它的工作正常。但是,如果他们选择

打开,文件下载(快速),但是当Word打开时,

临时互联网文件中的副本已经消失或从未保存在第一个

的地方。 Word显示有关无法找到文件的错误。


我怀疑它与缓存有关但我可以找到很多帖子

关于停止缓存,我在ASP.NET中找不到任何关于

迫使Word文档缓存的好例子。


任何想法?


谢谢,Rob。

We''ve implemented functionality to allow a user to download a document (any
document type) from the IIS server using the following code:

Response.Clear()
Response.ContentType = "application/x-msdownload"
Response.AddHeader("Content-Disposition", "attachment; filename=" &
System.IO.Path.GetFileName(FilePath))
Response.AddHeader("Content-Length", File.Length.ToString())
Response.WriteFile(FilePath)
Response.End()

When this response is sent back, IE prompts the user whether they want to
open, save or cancel the download. It works perfectly if they save the
document to their local hard drive and then open it. However, if they select
Open, the file downloads (quickly) but by the time Word opens, the copy in
temporary internet files has either disappeared or never saved in the first
place. Word displays an error about "The file could not be found".

I suspect it''s something to do with caching but whilst I can find many posts
about stopping caching, I can''t find any good examples in ASP.NET about
forcing the Word document to cache.

Any ideas?

Thanks, Rob.


推荐答案

似乎好像内容类型明确表示它是用于下载。尝试

使用application / doc;对于Word文件。这将告诉浏览器打开

吧。然后用户可以选择在本地保存它。


或者,尝试设置content-expiration。 IIS中目录的设置

在一分钟后到期(相对于立即)。 Word,PDF和其他人在浏览器中打开时会立即过期

问题。


" Rob Nicholson"写道:
It seems as if the content-type specifically says it is for downloading. Try
using "application/doc" for Word files. This will tell the browser to open
it. The user then can optionally save it locally.

Or, try setting the "content-expiration" setting for the directory in IIS to
expire in one minute(versus immediately). Word, PDF, and others have had a
problem being opened in the browser with expire-immediately.

"Rob Nicholson" wrote:
我们已经实现了允许用户使用以下代码从IIS服务器下载文档(任何
文档类型)的功能:

Response.Clear()
Response.ContentType =" application / x-msdownload"
Response.AddHeader(" Content-Disposition"," attachment; filename ="&
System.IO.Path.GetFileName(FilePath))
Response.AddHeader(" Content-Length",File.Length.ToString())
Response.WriteFile(FilePath)
Response.End()

当回复此响应时,IE会提示用户是否要打开,保存或取消下载。如果他们将
文档保存到本地硬盘驱动器然后打开它,它的工作正常。但是,如果他们选择打开,文件下载(快速),但是当Word打开时,临时互联网文件中的副本已经消失或从未保存在第一个
位置。 Word显示有关无法找到文件的错误。

我怀疑它与缓存有关但我可以找到很多关于停止缓存的帖子,我在ASP.NET中找不到任何关于强制Word文档缓存的好例子。

任何想法?

谢谢,Rob。

We''ve implemented functionality to allow a user to download a document (any
document type) from the IIS server using the following code:

Response.Clear()
Response.ContentType = "application/x-msdownload"
Response.AddHeader("Content-Disposition", "attachment; filename=" &
System.IO.Path.GetFileName(FilePath))
Response.AddHeader("Content-Length", File.Length.ToString())
Response.WriteFile(FilePath)
Response.End()

When this response is sent back, IE prompts the user whether they want to
open, save or cancel the download. It works perfectly if they save the
document to their local hard drive and then open it. However, if they select
Open, the file downloads (quickly) but by the time Word opens, the copy in
temporary internet files has either disappeared or never saved in the first
place. Word displays an error about "The file could not be found".

I suspect it''s something to do with caching but whilst I can find many posts
about stopping caching, I can''t find any good examples in ASP.NET about
forcing the Word document to cache.

Any ideas?

Thanks, Rob.



你好Rob,


我想你可以试试Brad的建议调整响应对象的内容类型

属性。根据您提供的代码,除了内容类型值之外,没有其他特殊内容可以使用
。一般来说,

我们总是可以使用application / octet-stream。对于所有二进制数据

溪流。

如果还有其他任何发现,请随时在此发布。


谢谢,


Steven Cheng

微软在线支持


安全! www.microsoft.com/security

(此帖子按原样提供,不作任何保证,并且不授予

权利。)

---------------- ----

| Thread-Topic:下载的文件已经消失了Word已经打开

打开

| thread-index:AcWuaqCYbyNdCVghSemc2lRBU + nUxA ==

| X-WBNR-Posting-Host:129.54.8.45

|从:=?Utf-8?B?QnJhZCBSb2JlcnRz?=< Br ***************** @ hotmail.com>

|参考文献:< uD ************** @ TK2MSFTNGP15.phx.gbl>

|主题:RE:下载的文件已经消失了Word已经开启

开启

|日期:2005年8月31日星期三13:29:03 -0700

|行数:40

|消息ID:< 0A ********************************** @ microsoft.co m>

| MIME版本:1.0

|内容类型:text / plain;

| charset =" Utf-8"

|内容传输编码:7位

| X-Newsreader:适用于Windows 2000的Microsoft CDO

| Content-Class:urn:content-classes:message

|重要性:正常

|优先级:正常

| X-MimeOLE:由Microsoft MimeOLE制作V6.00.3790.0

|新闻组:microsoft.public.dotnet.framework.aspnet

| NNTP-Posting-Host:TK2MSFTNGXA03.phx.gbl 10.40.2.250

|路径:TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl

|外翻:TK2MSFTNGXA01.phx.gbl

microsoft.public.dotnet.framework.aspnet:121534

| X-Tomcat-NG:microsoft.public.dotnet.framework.aspnet

|

|似乎内容类型明确表示它是用于下载。

尝试

|使用application / doc对于Word文件。这将告诉浏览器

打开

|它。然后用户可以选择在本地保存。

|

|或者,尝试设置内容过期。在IIS中设置目录



|在一分钟后到期(相对于立即)。 Word,PDF和其他人已经有了
a

|在浏览器中打开的问题立即过期。

|

| Rob Nicholson写道:

|

| >我们已经实现了允许用户使用以下代码从IIS服务器下载文件

(任何

|>文档类型)的功能:

| >

| > Response.Clear()

| > Response.ContentType =" application / x-msdownload"

| > Response.AddHeader(" Content-Disposition"," attachment; filename ="&

|> System.IO.Path.GetFileName(FilePath))

| > Response.AddHeader(" Content-Length",File.Length.ToString())

| > Response.WriteFile(FilePath)

| > Response.End()

| >

| >当回复此响应时,IE会提示用户是否需要



| >打开,保存或取消下载。如果他们保存

|,它的效果非常好>将文档发送到本地硬盘然后再打开它。但是,如果他们

选择

| >打开,文件下载(快速),但是当Word打开时,副本

in

| >临时互联网文件已经消失或者从未保存在

中首先

| >地点。 Word显示有关无法找到文件的错误。

| >

| >我怀疑它与缓存有关,但我可以找到很多

的帖子

| >关于停止缓存,我在ASP.NET中找不到关于

|的任何好例子>强制Word文档缓存。

| >

| >有什么想法吗?

| >

| >谢谢,Rob。

| >

| >

| >

| >

| >

|

Hi Rob,

I think you can try Brad''s suggestion on adjusting the Content Type
property of your response object. Based on the code you provided, there
seems no other particular things except the content-type value. Generally,
we can always use the "application/octet-stream" for all binary data
streams.
If there''re any other findings, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: Downloaded document has disappeared by the time Word has
opened
| thread-index: AcWuaqCYbyNdCVghSemc2lRBU+nUxA==
| X-WBNR-Posting-Host: 129.54.8.45
| From: =?Utf-8?B?QnJhZCBSb2JlcnRz?= <Br*****************@hotmail.com>
| References: <uD**************@TK2MSFTNGP15.phx.gbl>
| Subject: RE: Downloaded document has disappeared by the time Word has
opened
| Date: Wed, 31 Aug 2005 13:29:03 -0700
| Lines: 40
| Message-ID: <0A**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:121534
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| It seems as if the content-type specifically says it is for downloading.
Try
| using "application/doc" for Word files. This will tell the browser to
open
| it. The user then can optionally save it locally.
|
| Or, try setting the "content-expiration" setting for the directory in IIS
to
| expire in one minute(versus immediately). Word, PDF, and others have had
a
| problem being opened in the browser with expire-immediately.
|
| "Rob Nicholson" wrote:
|
| > We''ve implemented functionality to allow a user to download a document
(any
| > document type) from the IIS server using the following code:
| >
| > Response.Clear()
| > Response.ContentType = "application/x-msdownload"
| > Response.AddHeader("Content-Disposition", "attachment; filename=" &
| > System.IO.Path.GetFileName(FilePath))
| > Response.AddHeader("Content-Length", File.Length.ToString())
| > Response.WriteFile(FilePath)
| > Response.End()
| >
| > When this response is sent back, IE prompts the user whether they want
to
| > open, save or cancel the download. It works perfectly if they save the
| > document to their local hard drive and then open it. However, if they
select
| > Open, the file downloads (quickly) but by the time Word opens, the copy
in
| > temporary internet files has either disappeared or never saved in the
first
| > place. Word displays an error about "The file could not be found".
| >
| > I suspect it''s something to do with caching but whilst I can find many
posts
| > about stopping caching, I can''t find any good examples in ASP.NET about
| > forcing the Word document to cache.
| >
| > Any ideas?
| >
| > Thanks, Rob.
| >
| >
| >
| >
| >
|


>使用application / doc对于Word文件。这将告诉浏览器打开


这个问题是我们不必为每个

不同的内容类型编码/提供程序并生成不同的内容类型?
> using "application/doc" for Word files. This will tell the browser to open

The problem with this is that don''t we then have to code/cater for every
different content type in the program and generate different content-types?
或者,尝试设置内容过期。 IIS
中的目录设置在一分钟后到期(相对于立即)。 Word,PDF和其他人在浏览器中打开时会立即过期。
Or, try setting the "content-expiration" setting for the directory in IIS to expire in one minute(versus immediately). Word, PDF, and others have had a
problem being opened in the browser with expire-immediately.




这可能更有用。您将哪个目录设置为源文件夹的目的地为




谢谢,Rob。



Ahh this might be more useful. Which directory do you set the expiry on as
the source folder varies?

Thanks, Rob.


这篇关于Word打开时,已下载的文档已消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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