开发者

Open file from server and send to browser

In my asp.net application I create pdf file and save it in App_Data folder on server. Next I want to open this file that user can print it.

How to open this file in开发者_高级运维 browser ? Send it in http header etc ? Someone have some examples?

Please help ;)


you could save the file in a folder and then give the user a page where they can click on a link to download the file. just remember to create a unique name for the file (using guid) otherwise users will download each other's files.

you could also return the file in the response. the following code is for returning an excel file, but can be easily modified for pdf.

Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}", fileName)); 
Response.TransmitFile(Server.MapPath(string.Format("{0}/{1}", BasePath, fileName))); 


You could just redirect the user to it using Response.Redirect(). Then the user could decide if s/he wants to print it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜