Download, is it correct?

  • Thread starter Thread starter Marius Horak
  • Start date Start date
M

Marius Horak

Web application has the following code for downloading a file from a server

this.Context.Response.Clear();
this.Context.Response.BufferOutput = false;
this.Context.Response.ContentType = "application/octet-stream";
this.Context.Response.AddHeader("Content-Disposition","attachment;
filename=" + FileName);
// this.Context.Response.AddHeader("Content-Length",fileSize.ToString());
this.Context.Response.Flush();
this.Context.Response.WriteFile(FullFileName);
// this.Context.Response.Flush();
// this.Context.Response.End();

It runs after a button on a page is clicked.
The code apparently never worked. Code is being executed without errors but
nothing happens.
I checked some examples and they were more or less as the above code.
What could be wrong?
What should I expect with working code - the download dialog box?

Thanks

MH
 
What if you try a page with :

this.Context.Response.AddHeader("Content-Disposition","attachment;filename=m
yfile.txt");
this.Context.Response.Write("Hello World");

Make sure to clear the HTML the page may contains. From there you should be
able to add back more things until to find the culprit...

Patrice
 
Back
Top