C# 当我尝试用MVC下载pdf时,它只打开一个空白页,什么也不做
当我进行此调用时,它会返回内容、正确的mime类型和文件名。它只是无法下载 如果有人对如何解决这一问题有想法,我们将非常感谢您的帮助C# 当我尝试用MVC下载pdf时,它只打开一个空白页,什么也不做,c#,asp.net-mvc,jquery-mobile,pdf,C#,Asp.net Mvc,Jquery Mobile,Pdf,当我进行此调用时,它会返回内容、正确的mime类型和文件名。它只是无法下载 如果有人对如何解决这一问题有想法,我们将非常感谢您的帮助 public FileResult Download() { if (HelperClass.SessionNotExpired(Session)) { string caseNumber = Request.Params["CaseNumber"] as string; string fileName = Request.Params["
public FileResult Download()
{
if (HelperClass.SessionNotExpired(Session))
{
string caseNumber = Request.Params["CaseNumber"] as string;
string fileName = Request.Params["FileName"] as string;
if (!String.IsNullOrEmpty(caseNumber) && !String.IsNullOrEmpty(fileName))
{
Document doc = DropBox.Get(caseNumber, fileName, DocumentServiceRequestCodes.WEB, (string)Session[HelperClass.EMAIL], (string)Session[HelperClass.PASSWORD]);
var cd = new System.Net.Mime.ContentDisposition
{
// for example foo.bak
FileName = doc.FileName,
// always prompt the user for downloading, set to true if you want
// the browser to try to show the file inline
Inline = false,
};
Response.AppendHeader("Content-Disposition", cd.ToString());
return File(doc.Contents, GetMimeType(fileName), fileName);
}
}
return null;
}
如果内容是流,请尝试手动设置其位置 stream.Seek0,SeekOrigin.Begin 或
流位置=0 您确定doc不为NULL吗?doc.Contents的数据类型是什么?not NULL及其字节数组。