Removing response.End() includes the html of the page.

Posted by vinay_rockin on Stack Overflow See other posts from Stack Overflow or by vinay_rockin
Published on 2010-03-12T15:03:22Z Indexed on 2010/03/12 15:07 UTC
Read the original article Hit count: 168

Filed under:
|
|
HttpResponse response = Context.Http.Response;
response.Headers.Clear();
response.Clear();
response.ContentType = Component.OverrideMimeType ? Component.MimeType : "application/download";
response.AppendHeader("Content-Disposition", 
String.Format("attachment; filename=\"{0}\"", HttpUtility.HtmlEncode(Path.GetFileName(file.FileName))));
response.OutputStream.Write(file.Contents, 0, file.Contents.Length);
response.Flush();
// response.End();

if I use response.End() it throws exception and if I comment response.End() it includes the html of the page on which the download link resides. how want to download file with introducing this exta html.

Any Idea how to fix this?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#