【发布时间】:2017-11-24 08:02:46
【问题描述】:
我需要在点击按钮时在 aspx 页面内显示 pdf 文件(使用 asp.net 控件)。
我目前已执行以下代码,该代码在 Web 浏览器中显示 pdf 文件。
string folderPath =
Server.MapPath(ConfigurationManager.AppSettings["serverFolderPath"].ToString());
foreach (string file in Directory.GetFiles(folderPath))
{
WebClient user = new WebClient();
Byte[] fileBuffer = user.DownloadData(file);
if (fileBuffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", fileBuffer.Length.ToString());
sponse.BinaryWrite(fileBuffer);
}
}
【问题讨论】:
-
你可以使用 iframe 检查参考codeproject.com/Articles/20699/…