如何在asp.net中打开MS Office的词吗? [英] how to open MS Office word in asp.net?

查看:123
本文介绍了如何在asp.net中打开MS Office的词吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,当特定的链接按钮,用户点击,微软Word不得不打开我怎么能写code这一点。谢谢

in my application, when user click on particular link button, MS word has to open how can i write the code for this. Thank you

推荐答案

有没有办法保证当用户点击网页上的链接/按钮,一个特定的应用程序将被打开。在打开的应用程序是由用户的浏览器和操作系统设置确定。

There is no way to guarantee that a particular application will be opened when a user clicks a link / button on a web page. The application that is opened is determined by the user's browser and operating system settings.

正如你可以指定 MIME类型开发商。通过这样做,你是在告诉什么文件类型包含在响应用户的浏览器。 W3Schools的提供了pretty好 MIME类型内容类型列表和的 FILExt 还提供了MIME类型它列出的文件。

As a developer you can specify the MIME type of the file that you are returning. By doing so you are telling the user's browser what file type is contained in the response. W3Schools provides a pretty good MIME type by content type list and FILExt also provides the MIME type for the files it lists.

假设你指定合适的MIME内容类型可以确保用户的浏览器和操作系统将根据其设置在适当的应用程序打开该文件。既然你要打开一个Word文档文件的相应MIME内容类型将是下列之一:

Assuming you specify the appropriate MIME content-type you can be sure the user's browser and operating system will open the file in the "appropriate" application according to their settings. Since you want to open a Word Document file the appropriate MIME content-type will be one of the following:


 **Extension Type/sub-type**
 docx      application/vnd.openxmlformats-officedocument.wordprocessingml.document
 doc       application/msword
 

如何以及在哪里你指定的内容类型在很大程度上取决于您正在使用的ASP.NET应用程序类型。如果你正在写一个ASP.NET Web表单应用程序,你会改变MIME类型在Page_Load方法响应的对象。在ASP.NET MVC应用程序你会在控制器的行动这样做。在这两种情况下code的特定行是相同的。

How and where you specify the content-type largely depends on the ASP.NET application type you are working with. If you are writing a ASP.NET Webforms application you'd change the MIME type of the Response object in the Page_Load method. In an ASP.NET MVC application you'd do so in a controller action. In either case the specific line of code is the same.

Response.ContentType = "application/msword";

这篇关于如何在asp.net中打开MS Office的词吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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