C# 改为在浏览器窗口中显示*doc、*xls、*pdf
我想在浏览器窗口中显示*doc、*xls、*pdf,而不是它们的应用程序。我尝试了以下代码,但没有成功,它提示我保存/打开对话框,而不是在浏览器中显示C# 改为在浏览器窗口中显示*doc、*xls、*pdf,c#,asp.net,.doc,C#,Asp.net,.doc,我想在浏览器窗口中显示*doc、*xls、*pdf,而不是它们的应用程序。我尝试了以下代码,但没有成功,它提示我保存/打开对话框,而不是在浏览器中显示 //Set the appropriate ContentType. Response.ContentType = "Application/msword"; //Get the physical path to the file. string FilePath = MapPath("wordfile.doc")
//Set the appropriate ContentType.
Response.ContentType = "Application/msword";
//Get the physical path to the file.
string FilePath = MapPath("wordfile.doc");
//Write the file directly to the HTTP content output stream.
Response.AppendHeader("Content-Disposition", "inline;filename=" + "wordfile.doc");
Response.WriteFile(FilePath);
Response.End();
请帮忙感谢为IE提供浏览器插件/扩展或ActiveX所需的任何这些专有格式
我不确定它是否适用于office格式。
对于PDF,将
内容类型设置为“application/PDF”
和内容处置设置为inline
应该可以工作。如果浏览器不支持此功能,则无法执行此操作。这有点像问“为什么我不能在绘画中打开文档?”。。。