|
-
Jul 16th, 2008, 01:23 PM
#1
Thread Starter
New Member
[2005] Force download prompt for xml file
I'm new to ASP .NET and Visual Basic .NET.
I'm sure this has been asked but a quick search didn't bring anything up for me that helped. What I want to do is convert a XmlDocument into a xml file and have it prompt the user to download the xml file when a button is clicked.
I don't know where to begin so any examples of how to convert a XmlDocument to a xml file and prompt to save that file would be great. Thanks
-
Jul 16th, 2008, 02:45 PM
#2
Fanatic Member
Re: [2005] Force download prompt for xml file
I think you need to change content type association while sending the XML document from server to client side. This article might help you.
-
Jul 16th, 2008, 03:43 PM
#3
Re: [2005] Force download prompt for xml file
Once you write the XmlDocument to disk, you can do Response.WriteFile().
-
Jul 16th, 2008, 04:32 PM
#4
Fanatic Member
Re: [2005] Force download prompt for xml file
Generally all XML files open up in the browser as their MIME types are defined. So I guess Response.WriteFile() will open the XML in browser (am I wrong?) but what OP wanted was to force download the file.
-
Jul 17th, 2008, 03:26 AM
#5
Re: [2005] Force download prompt for xml file
Like this:
Code:
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=myfile.xml");
Response.WriteFile("C:\\Documents and Settings\\blah\\Desktop\\myfile.xml");
Last edited by mendhak; Jul 17th, 2008 at 03:30 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|