Saving Downloaded Xml from ASPX page as File

  • Thread starter Christopher D. Wiederspan
  • Start date
C

Christopher D. Wiederspan

I've got an ASPX page that simply builds an Xml document and does a
Response.Write back to the client with that Xml, something like this:

// Get the content as the Xml contained within the current working model
string content = someDataSet.GetXml();

// Write the response back to the user's stream
this.Response.Clear();
this.Response.ContentType = "text/xml";
this.Response.Write(content);
this.Response.End();


Right now, this causes IE to just display the data in it's typical Xml
incarnation - it's default behavior. My intention is that the user will
recieve the Save As... dialog box and can save this Xml to a file on their
machine instead of actually having to view it and manually use the browsers
Save As... menu item from the File menu. Part of the problem is that this
Xml file is produced via a local Intranet and is fairly large (say 10 MB).
When IE tries to actually parse and display the Xml, it takes forever.

I'm wondering if there is some other ContentType value that might cause the
trigger the Save As dialog immediately...?

Any ideas would be greatly appreciated.

Thanks,
Chris
 
C

Christopher D. Wiederspan

Got it! After further investigation, I stumbled across the
Content-Disposition header that you can set to force the Save As dialog box.
Worked like a charm.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top