在客户端发布开放的word/pdf文档. [英] issue opening word/pdf document on client side.

查看:132
本文介绍了在客户端发布开放的word/pdf文档.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在本地打开word/pdf文档时,它工作正常.
但是当我在服务器上发布时却报错.

我不知道为什么需要帮助.
这是我的代码

第一种方法

When i am trying to open a word/pdf document locally it is working fine.
But when i publish on server it is giving error.

i dont know why need help.
here is My Code

1st Method

Process p = new Process();
p.StartInfo.FileName = Server.MapPath(BuildString);
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.Start();



第二种方法



2nd Method

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", newFilename.Name);
Response.WriteFile(FileName);
Response.End();



第三种方法



3rd Method

System.Diagnostics.Process.Start(FileName);

推荐答案

这是预期的结果.这些方法均无效.看来您不知道在服务器端和客户端会发生什么.方法#1和#3在服务器端运行,与将内容显示给客户端无关,#2只是将内容转储到响应,因此它是客户端在请求时接收到的,但这不是上下文的方式使用处置;请参阅以获取更多详细信息:
http://www.ietf.org/rfc/rfc1806.txt [ http://www.ietf.org/rfc/rfc2183.txt [ http://www.ietf.org [ ^ ])) ,
http://support.microsoft.com/kb/260519 [ http://stackoverflow.com/questions/1012437/uses- of-content-disposition-in-an-http-response-header [
This is the expected result. None of these method should work. It looks like you have no idea what happens on server and client sides. Methods #1 and #3 run on server side and have nothing to do with showing the content to client side, #2 just dumps the content to the response, so it is received by the client side on request, but this is not how context disposition is used; see for more detail:
http://www.ietf.org/rfc/rfc1806.txt[^],
http://www.ietf.org/rfc/rfc2183.txt[^] (always check things with http://www.ietf.org[^]),
http://support.microsoft.com/kb/260519[^],
http://stackoverflow.com/questions/1012437/uses-of-content-disposition-in-an-http-response-header[^].

You could simply write simple HTML code with anchor; most browsers support PDF and will show it as a Web page:

<a href="myFile.PDF">See PDF Document</a>



—SA



—SA


这篇关于在客户端发布开放的word/pdf文档.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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