Results 1 to 5 of 5

Thread: [2005] Force download prompt for xml file

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    7

    [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

  2. #2
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    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.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Force download prompt for xml file

    Once you write the XmlDocument to disk, you can do Response.WriteFile().

  4. #4
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    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.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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
  •  



Click Here to Expand Forum to Full Width