DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Open Save Dialog Box To Download File

12.30.2011
| 3828 views |
  • submit to reddit
        // Open save dialog box to download file

string attachment = "attachment; filename=" myfile.xml";
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.AddHeader("content-disposition", attachment);
            HttpContext.Current.Response.ContentType = "text/xml";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
            HttpContext.Current.Response.TransmitFile(Server.MapPath(filepath));
            HttpContext.Current.Response.End();

<a href="http://www.java-forums.org/java-software/"><strong>Java Software</strong></a>