使用.NET 向浏览器写入二进制文件
2008-05-01 04:13
225 查看
1、确保要从其上查看 .aspx 页的客户端计算机上已安装了 Adobe Acrobat Reader,以便浏览器能够正确读取并呈现二进制数据。可以从以下 Adobe 网站下载 Adobe Acrobat Reader: http://www.chinese-s.adobe.com/main.html (http://www.adobe.com)
2、确保将您的页面添加到项目中在上一节中添加的 .pdf 文件所在的级别。这一点非常重要,因为代码最初引用 .pdf 文件时采用相对路径。
在代码隐藏页的 Page_Load 事件中,单击“编辑”菜单上的“粘贴”以粘贴代码:
在代码隐藏页的 Page_Load 事件中,加入以下代码:
private void Page_Load(object sender, System.EventArgs e)
...{
//Set the appropriate ContentType.
Response.ContentType = "Application/pdf";
//Get the physical path to the file.
string FilePath = MapPath("acrobat.pdf");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();
}
2、确保将您的页面添加到项目中在上一节中添加的 .pdf 文件所在的级别。这一点非常重要,因为代码最初引用 .pdf 文件时采用相对路径。
在代码隐藏页的 Page_Load 事件中,单击“编辑”菜单上的“粘贴”以粘贴代码:
在代码隐藏页的 Page_Load 事件中,加入以下代码:
private void Page_Load(object sender, System.EventArgs e)
...{
//Set the appropriate ContentType.
Response.ContentType = "Application/pdf";
//Get the physical path to the file.
string FilePath = MapPath("acrobat.pdf");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();
}
相关文章推荐
- 使用.NET 向浏览器写入二进制文件
- 如何使用 ASP.NET 和 Visual C# .NET 向浏览器写入二进制文件
- 使用C++将OpenCV中Mat的数据写入二进制文件,用Matlab读出
- C#使用BinaryWriter类写入二进制文件1
- 使用C++将OpenCV中Mat的数据写入二进制文件,用Matlab读出
- .Net 下使用ODBC连接xls文件写入大文本的解决办法
- 使用.NET 向浏览器写入二进制文件
- 使用C++将OpenCV中Mat的数据写入二进制文件,用Matlab读出
- 使用C++将OpenCV中Mat的数据写入二进制文件,用Matlab读出
- <Android>使用缓冲区实时写入文件一
- CSV文件的使用-写入/写出(C++/Python)
- 浏览器加载静态文件时,是否使用浏览器已缓存的文件的相关策略。
- 解决.net网站打开出现编译器错误消息: CS0016: 未能写入输出文件问题
- 【C#】使用StreamWriter类写入文件
- VC++ 读取二进制文件以及写入文件简单示例:
- 使用虚拟机报.o错误 清楚二进制文件
- 浏览器环境下js对文件进行写入
- 在.net下使用配置文件
- 文件部分-----(6 )二进制文件读写操作----将学生信息写入到文件中,再从文件中读取信息
- Linux 如何使用echo指令向文件写入内容