问题描述
protectedvoidPage_Load(objectsender,EventArgse){stringfilepath=Server.MapPath("~/UpLoadFile/"+caseNo+"/"+filename);FileStreamfs=newFileStream(filepath,FileMode.Open,FileAccess.Read);byte[]bytes=newbyte[(int)fs.Length];fs.Read(bytes,0,bytes.Length);fs.Close();Response.ContentType=GetContentType(filename);Response.Charset="utf-8";Response.ContentEncoding=Encoding.GetEncoding("utf-8");Response.OutputStream.Write(bytes,0,bytes.Length);Response.End();}privatestringGetContentType(stringfileName){string_contentType=string.Empty;if(fileName.EndsWith("doc")){_contentType="application/msword";}if(fileName.EndsWith("docx")){_contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document";}if(fileName.EndsWith("xls")){_contentType="application/vnd.ms-excel";}if(fileName.EndsWith("xlsx")){_contentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";}if(fileName.EndsWith("jpg")||fileName.EndsWith("jpe")||fileName.EndsWith("jpeg")){_contentType="image/jpeg";}if(fileName.EndsWith("png")){_contentType="image/png";}if(fileName.EndsWith("gif")){_contentType="image/gif";}if(fileName.EndsWith("bmp")){_contentType="image/bmp";}if(fileName.EndsWith("pdf")){_contentType="application/PDF";}if(fileName.EndsWith("ppt")){_contentType="application/vnd.ms-powerpoint";}return_contentType;}
解决方案
解决方案二:
ie有查看pdf的插件吗?
解决方案三:
ie11及以上有其他的没有自带的