开发者

How does Response.ContentType work?

I am downloading an xml string from ASP.Net and want it to open in MS Office Infopath. I set the ContentType to "application/ms-infopath.xml" (not sure where I got that from).

On some machines it is fine, on others the xml opens in the browser, or in Visual Studio or some 开发者_运维技巧other xml editor, even though Infopath is present.

  1. Who keeps the list of valid content types?
  2. What does the OS or browser do with it?
  3. How can I force this XML to open in the program of my choice (Infopath)?


I know this question is really old, but I had the same problem.

I trolled through all the file types on windows trying to find one that only opens in infopath - and there actually is one! Every default install of office has the file extension ".infopathxml" set to open with infopath. So just set your file= part of content_disposition header to "whatever.infopathxml".

xml does not map to any program by default, but will tend to open in whatever someone last used (usually IE's viewer or visual studio), while almost no one will change what .infopathxml files open in.

As I understand it, its still left to the end user. Content-type specifies how the data should be read and verified, but its up to the end user which extension is mapped to which program. You can't force xml to open in one program anymore than you specify which zip program a zip file should open in... the only thing you can do is use a file extension that is almost certain to be unique for that program, such as .infopathxml in this case.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜