打印

[NET精华教程] .net教程:使用.net 向浏览器写入二进制文件

.net教程:使用.net 向浏览器写入二进制文件

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();
    }
                     



TOP

返回顶部
AYBlue

Processed in 0.057496 second(s), 7 queries.

当前时区 GMT+8, 现在时间是 2009-1-8 14:41 京ICP备06054220号

清除 Cookies - 联系我们 - 163K.com - Archiver - WAP