当前位置:编程学习 > C#/ASP.NET >>

在浏览器中显示pdf文件,ie成功,chrome失败

我是在浏览器中显示图片或者pdf文件 但是pdf文件只能在ie中显示 在chrome中打开时一直显示正在载入 chrome后台显示 failed to load resource 网上查了一下说是chrome对Response.Flush()反应机制跟ie不同 请问哪位高手知道怎么解决 代码如下:

int ID=int.Parse(Session["IMGID"].ToString());
  string p=UserManager.GetIMGDetails(ID).Rows[0]["FileName"].ToString();
  string filepath = Server.MapPath("~/UploadFiles/" + p);
  Response.ClearContent();
  Response.ClearHeaders();
  string filepost=UserManager.GetIMGDetails(ID).Rows[0]["FileType"].ToString();
  switch (filepost)
  {
  case ".pdf":
  Response.ContentType = "application/PDF";
  break;
  case ".jpg":
  Response.ContentType = "image/jpeg";
  break;
  default:
  Session["ErrorInfo"] = "不支持的文件格式:" + filepost;
  Response.Redirect("ErrorPage.aspx");
  break;
  }
  Response.WriteFile(filepath);
  Response.Flush();
  Response.Close();
  Session.Remove("Report");
  Session.Remove("IMGID"); --------------------编程问答--------------------

地址栏输入chrome://plugins/ 回车就能看到PDF的项目

baidu 到这个,不知道有用否?
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,