Geekpedia Forums Logo

Xml file export leaves webpage open??

by venkatesh padmanabhan on Tuesday, August 21st - 3:34 AM



Hi..

I have a web application(ASP.NET 2.0, C#), in which I am exporting a xml file.

The web page has a button called Export. When the user clicks the Export button, the File Download pops up, in which it has the Open,Save and Cancel Butons as in a normal file download pop-up. Being an xml file, the page also opens up,without the content behind the File download pop-up,

When the user clicks Cancel button, the file download pop up is gone, but the xml page(without the contents) is still open. This also happens when the user has successfully downloaded the xml file(Xml page is open)

Is it possible to close the xml page after the user clicks the cancel button and after the user saves the xml file? I am using Internet Explorer 6, Windows xp, SP1.

Please help.. Thanks

It appears that the browser is initiating the download dialog and opening the file at the same time. Are you sending the headers to the client yourself? If that's the case, you might want to check the mime type info that you are sending.

Thank you very much for the Reply.

This is the code i have used:

Response.AddHeader(

Response.ContentType =

Response.Write(StrategyXml);

Response.Flush();

Response.SuppressContent =

How to check the mime type and then close the xml page, during the cancel button click of the download pop-up and after saving the xml file?

Please help.

"Content-Disposition", "attachment; filename=" + StrategyName + ".xml");"application/xml";true;

What you need to do is to prevent the XML file from opening in the window in the first place. The way to do that is most likely by changing the mime type to one that's handled better by Internet Explorer. Try changing the mime type from application/xml to  text/xml and note if there are any changes. Also try using application/octet-stream.

Hi..

Thank you very much for the reply.

I tried putting:

Response.ContentType =

and the text also.. But the page was opening at first itself.

How to tackle this? Please help.

Thanks

"application/octet-stream";