R
R
RedQuark2012-10-23 13:21:06
HTML
RedQuark, 2012-10-23 13:21:06

How to properly give a file for IE9?

I do it like this:

Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
Response.AddHeader("Content-Type", type);
Response.ContentEncoding = Encoding.Default;
Response.HeaderEncoding = Encoding.Default;
Response.WriteFile(path);

Works! But if the rar archive (for example) left-click and Open, and then click Exit rara and right-click the link "Save object as" then the file name is: getfile.htm (where getfile.aspx is the page in the body of which and the file is placed). If you agree and save, then rar will open it (the file body is correct). Now if you do “Save object as” a second time, then the file name will be correct. If, when opening the page, click on the link once (it doesn’t matter “Save object as” or “Open”), then the name will be correct. So why does IE9, when combined: “Open”, “Exit”, “Save target as”, give the page name in the file name? I checked this algorithm on other sites - this effect is not observed. So I'm giving it wrong?
PS: in FF, Chrome no problem, IE 9.0.8112.16421.
PSS: I found exactly the same error with the name, not at my place, but in a large project written for SharePoint

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lumega, 2012-10-23
@lumega

If you have access to the web server settings, then you can do it radically, make a rewrite URL so that your script is before the file name, for example:
/script_hadle/file.ext

T
truekenny, 2012-10-23
@truekenny

Try

Content-Type: file/file; name="video.mpg"
Content-disposition: attachment; filename="video.mpg"

L
lumega, 2012-10-23
@lumega

you can pass the name of the file in the header.
Content-Disposition: attachment; filename="fname.ext"
see here en.wikipedia.org/wiki/List_of_HTTP_header_fields

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question