【发布时间】:2012-01-07 19:21:39
【问题描述】:
这是下载文件的代码。
System.IO.FileStream fs = new System.IO.FileStream(Path+"\\"+fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] ar = new byte[(int)fs.Length];
fs.Read(ar, 0, (int)fs.Length);
fs.Close();
Response.AddHeader("content-disposition", "attachment;filename=" + AccNo+".pdf");
Response.ContentType = "application/octectstream";
Response.BinaryWrite(ar);
Response.End();
执行此代码时,它将要求用户打开或保存文件。而不是这个,我需要打开一个新的选项卡或窗口 并显示文件。我怎样才能做到这一点?
注意:
文件不必位于网站文件夹中。它可能位于其他文件夹中。
【问题讨论】:
-
你可以试试
content-disposition: inline而不是attachment- See this article -
这篇文章可能对你有所帮助aspalliance.com/…