开发者

How Can I stop Internet Explorer from automatically displaying XML?

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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜