• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
Downloading Attachment using Response.AddHeader("content-disposition", attachment) issue:
by (1.4k points)  
reshown by

5 Answers

0 votes
HTML encoding are being used in the filename.

My suggestons would be HTTP headers should not be treated as HTML.
by (9.8k points)  
0 votes

Response.AddHeader("content-disposition", attachment)

You can use the following code for IE6 i have tried and it works for me like magic.

In IE 6 we have to use buffers,

FileStream file1 = new FileStream(FilePath(@"FName"), FileMode.Open);

float FSize;

FSize;= file1 .Length;

byte[] getContent = new byte[(int)FSize];

Response.AddHeader("Content-Length", getContent.Length.ToString());

Response.AddHeader("Content-Disposition", "attachment; filename=" + FName);


by (9.8k points)  
0 votes

I also tried this and it worked for me for issue of Response.AddHeader(“Content-Disposition”) not opening file in IE6

Response.ContentType = "application/octet-stream";
by (9.8k points)  
0 votes




Content-disposition header is important because it tells the browser not to load this content but download it instead it can also define the file name of the file getting downloaded so it's an opportunity to raise a file download dialog box.

The Content-Disposition response-header field allows origin server to provide a suggested filename if the user want to save it to specific file they want to save it to.

Some code examples for Content-Disposition:

        content-disposition = "Content-Disposition" ":"

       disposition-type *( ";" disposition-parm )

The main line of code for this:

Content-Disposition: attachment; filename="File123.ext"


See following links for details:



by (9.8k points)  
0 votes

Content Disposition Values / Parameters

Available formats are as following:

XML, HTML, Plain text

Content Disposition Values

Available formats:

inline [RFC2183]

attachment [RFC2183]

form-data [RFC7578]

signal [RFC3204]

alert [RFC3261]

icon [RFC3261]

render [RFC3261]

recipient-list-history [RFC5364]

session [RFC3261]

aib [RFC3893]

early-session [RFC3959]

recipient-list [RFC5363]

notification [RFC5438]

by-reference [RFC5621]

info-package [RFC6086]

recording-session [RFC7866]

by (9.8k points)  
edited by