C#-WEB:打开保存在数据库中的PDF [英] C#-WEB:Open a PDF saved in the database

查看:61
本文介绍了C#-WEB:打开保存在数据库中的PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的程序中,用户可以上传保存在SQL Server中的PDF文件。但是当我尝试检索文件时,它就不会打开。我使用以下代码:


_ObjUC = new UserControls();

DataTable dt = new DataTable();


_ObjUC.DocumentID = Request.QueryString [" id"]。ToString()。Trim();

dt = _ObjUC.getPDFdocument(_ObjUC.DocumentID);


byte [] buffer =(byte [])dt.Rows [0] [" document_content"];


Response.ContentType =" application / pdf";

Response.AddHeader(" Content-Type"," application / pdf");

Response.AddHeader(" content-disposition"," inline; filename = file.pdf");

MemoryStream PageData = new MemoryStream(buffer);

PageData.WriteTo(Response.OutputStream);


我们使用共享开发环境。有趣的是,它适用于我的同事comp但不适用于我的同事。我们都用户IE 7.0。我在这里做错了吗?还有另一种方法吗?

In my progr, users can upload PDF files which are saved in SQL Server. But when I try to retrieve the file, it just won''t open. I am using the following code:

_ObjUC = new UserControls();
DataTable dt = new DataTable();

_ObjUC.DocumentID = Request.QueryString["id"].ToString().Trim();
dt = _ObjUC.getPDFdocument(_ObjUC.DocumentID);

byte[] buffer = (byte[])dt.Rows[0]["document_content"];

Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("content-disposition", "inline;filename=file.pdf");
MemoryStream PageData = new MemoryStream(buffer);
PageData.WriteTo(Response.OutputStream);

We use a shared development environment. The funny thing is that it works on my collegues comp but not on mine. We both user IE 7.0. Am I doing something wrong here? Is there an alternate way?

推荐答案

当你说不打开时你什么意思?怎么了?你有一个保存对话框并且文件已损坏,或者根本不会下载?
When you say "won''t open" what do you mean? What happens? Do you get a save dialog and the file is corrupted, or will it not download at all?


No ...我得到的只是一个空白屏幕
No ... all I get is a blank screen


什么的空白屏幕?的Adobe? IE浏览器?火狐?请跟我一起工作吧!

我只能像你一样有帮助!
Blank screen in what? Adobe? IE? Firefox? PLEASE WORK WITH ME HERE!
I can only be as helpful as you are!


这篇关于C#-WEB:打开保存在数据库中的PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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