What is the correct usage of this code?
httpContext.Response.AddHeader("Content-Disposition", "inline; filename=" + HttpUtility.UrlPathEncode(fileName));
httpContext.Response.ContentType = "image/png";
httpContext.Response.AddHeader("Content-Length", new FileInfo(physicalFileName).Length.ToString());
httpContext.Response.TransmitFile(physicalFileName);
httpContext.Response.Flush();
httpContext.Response.End(); //Use it or not?
Is it really good to use .Flush()
and .End()
?
According to this you should never ever use Response.End()
(only in error or hacking scenarios)
But in some of the answers the .End()
is reconmended...?
Like in this article.
So it is appropriate to use Response.End
or not?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…