这是处理程序代码:如果我直接导航到此处理程序,它显示PDF罚款。在Aspx页面上我有一个图像控件,pdf不会在imagecontrol中显示。 Accroding所有的谷歌搜索这应该在图像控件中显示aspx页面上使用ashx(处理程序)文件打开pdf
public void ProcessRequest(HttpContext context)
{
WebClient imageWebClient = new WebClient();
byte[] imageBytes = imageWebClient.DownloadData(Testlocation);
context.Response.ClearHeaders();
//context.Response.ClearContent();
context.Response.AddHeader("content-disposition", "inline; filename=image.pdf");
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("Content-Length", imageBytes.Length.ToString());
context.Response.BinaryWrite(imageBytes);
context.Response.Flush();
}
标记:
您正在讨论图像控制 - 我无法在文档中看到任何指定它可以显示pdf的地方 –