Question

How to immediately open file in MS Office Project when I click a xml file in ASP.Net. Now open default xml editor.

The code of downloading xml file is

Response.ContentType = "application/vnd.ms-project";
Response.AppendHeader("Content-Disposition", "attachment; filename=file.xml");

UPDATE There is a button on my web page. When user click on button begins downloading ms project file in xml format. I need to do that when user choose "open file" in browser download dialog, file opens in MS Project

Was it helpful?

Solution

By using Content-Disposition with attachment specified, you are telling the browser to do just what is currently happening; the file is treated like a download of a file called file.xml.

If you don't want the file to be downloaded, try removing that header altogether. Note that it is still not guaranteed that the browser will be able to open Project since it depends on browser configuration and what is installed on the user's computer.

If you do want the file downloaded but for the browser to open it in Project after it's downloaded, you need to change the file extension in your filename header value to the correct file extension for Microsoft Project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top