单击电子邮件上的链接时,以下代码会导致在浏览器中打开PDF文档:
Response.ContentType = mime;
Response.WriteFile(path);
HttpContext.Current.ApplicationInstance.CompleteRequest();有没有办法强制客户端在Adobe Acrobat/reader中以本机方式打开它?
发布于 2012-02-01 00:34:24
客户端的行为取决于几个方面,包括客户端设置……你可以试试这个
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename="+filePath);
Response.WriteFile(path);
HttpContext.Current.ApplicationInstance.CompleteRequest();发布于 2012-02-01 00:42:02
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition","attachment; filename=SailBig.pdf");
Response.TransmitFile( Server.MapPath("~/images/sailbig.pdf") );
Response.End();这里有一些有用的信息可以帮助您:Downloading a File with a Save As Dialog in ASPNET和c# dynamically rename file upon download request,如果您正在使用MVC,还可以使用Handling file downloads using ASP.NET MVC
发布于 2012-02-01 00:35:11
你能做的最好的事情就是添加一个content-disposition头。这将导致出现下载文件对话框。
Response.AddHeader("content-disposition", "attachment;filename=xxx.pdf");https://stackoverflow.com/questions/9083047
复制相似问题