0

file name: abc.aspx

my code:

string Path = @"E:\documents\Data20160129110355.xls";
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "inline; filename=Data20160129110355.xls");

HttpContext.Current.Response.TransmitFile(Path);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();

On click of "Open" it will open the file successfully but the header of the file are not showing "Data20160129110355.xls". It's showing abc.aspx.

How to solve this problem please reply.

1 Answers1

1

Hope this will help:

Content-Disposition:What are the differences between "inline" and "attachment"?

replace 'inline' with 'attachment'.

UP: try this:

HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=Data20160129110355.xls");

Community
  • 1
  • 1
  • It is a good practice to provide a gist of the content in the provided link as part of the answer. – 4J41 Apr 08 '16 at 11:17
  • But not the same results, inline will show the file (eg a PDF, JPG, etc) in the browser window for viewing purposes. An Attachment, will force the file to be downloaded to the file system, which if you just want to see the graphic, is a waste of time. – Benjamin Schollnick Apr 18 '21 at 11:39