Is there anyway to force Internet Explorer to prompt for download of XML files instead of automatically displaying them? A code solution or just a set of IE configuration steps would be fine.
Even 开发者_运维问答if I use the wrong extension, IE uses "content sniffing" to determine that is XML and opens it automatically anyway.
I'd rather have the Open/Save/Cancel dialog instead.
Thanks in advance
You need to set the Content-Disposition HTTP header to "attachment". Doing this will be different depending on which framework or web-server you're using. For instance, in PHP you can use the following code:
header('Content-Disposition: attachment; filename="myfile.xml"');
header('Content-Type: application/xml');
精彩评论