Response.writefile()方法在asp.net中写入空页 [英] Response.writefile() method writes empty page in asp.net
问题描述
大家好,
我遇到了一个问题,我正在使用Response.writefile()方法编写一个pdf文件,它正在从ie6开始工作到使用visual studio的本地机器中的ie10,但是在生产服务器上从ie8到ie10没有工作。我使用的代码是
Dim fi作为新FileInfo(Server.MapPath(../ temp / ChequeBounceLetter-&SessionId&.pdf))
if fi.Exists Then
Response.ClearContent()
Response.ContentType ==application / pdf
Response.AddHeader (Content-Disposition,attachment; filename =+ fi.Name)
Response.AddHeader(Content-Length,fi.Length.ToString())
Response.WriteFile(fi.FullName)
Response.End()
请给我一些想法......提前谢谢
Hi all,
I am stucked with an issue that, i am writing a pdf file using Response.writefile() method and it is working in from ie6 to ie10 in local machine with visual studio, but not working in from ie8 to ie10 on production server. the code i used is
Dim fi As New FileInfo(Server.MapPath(../temp/ChequeBounceLetter- & SessionId &.pdf))
If fi.Exists Then
Response.ClearContent()
Response.ContentType == "application/pdf"
Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name)
Response.AddHeader(Content-Length, fi.Length.ToString())
Response.WriteFile(fi.FullName)
Response.End()
Pls suggest me some ideas .... thanks in advance
推荐答案
// Try This :
byte[] fileBytes = File.ReadAllBytes(fi.FullName);
Response.Clear()
Response.ContentType == "application/pdf"
Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name)
Response.AddHeader(Content-Length, fileBytes.Length.ToString());
Response.BinaryWrite(fileBytes);
Response.End();
这篇关于Response.writefile()方法在asp.net中写入空页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!