从ASP.NET应用程序打开Word文档 [英] Open word document from ASP.NET application

查看:106
本文介绍了从ASP.NET应用程序打开Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码段打开本地docx文件,当我在Visual Studio中按Ctrl + F5时,它运行良好.我只需单击按钮,机器上的Word2007就会打开,并且docx会显示在此处.但是,当我将应用程序发布到生产服务器后,它不起作用了.单击相同的按钮后,什么都没有发生.有人可以告诉我为什么吗?

I use the following code snippet to open a local docx file and it runs fine when I press Ctrl+F5 in Visual Studio. I just click the button and the Word2007 on my machine is opened and the docx is displayed there. But after I publish the application to the production server, it didn't work. After I click the same button, nothing happened. Could someone tell me why?

我想要的是从asp.net应用程序在客户端的Word 2007中打开本地存储的docx.我不想使用Office COM对象.

What I want is to open a local stored docx in client side's Word 2007 from asp.net application. I don't want to use office COM object.

我的代码:

    ProcessStartInfo psi = new ProcessStartInfo(@"winword.exe",@"/test.docx");
    Process.Start(psi);  

非常感谢.

推荐答案

您的代码正在尝试在服务器而非客户端上打开Word.它在开发中起作用的唯一原因是客户端和服务器在同一台计算机上.

Your code is attempting to open Word on the server and not on the client. The only reason it works in development is the the client and server are on the same machine.

由于浏览器安全限制,您无法在客户端上打开Word.但是,如果您提供该文件的链接,则如果用户安装了Word,则用户将能够下载并打开该文件.

You cannot open Word on the client due to browser security restrictions. However if you provide a link to the file, the user will be able to download and open the file if they have Word installed.

这篇关于从ASP.NET应用程序打开Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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