这是下载文件的代码。如何在新选项卡或窗口中打开PDF文件而不是下载它(使用asp.net)?
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();
当执行此代码时,它会要求用户打开或保存该文件。代替这个,我需要打开一个新标签或窗口并显示该文件。我怎样才能做到这一点?
注:
文件将没有必要设在网站上的文件夹。它可能位于其他文件夹中。
你可以试试'内容处置:inline',而不是'attachment' - [参见这篇文章(http://dotanything.wordpress.com/2008/05/30/content-disposition-attachment-vs-inline /) –
这篇文章可以帮助你http://aspalliance.com/259_downloading_files__forcing_the_file_download_dialog –