Wednesday, 12 September 2012

download file from asp.net page

Use Following Steps


string strURL = ConfigurationManager.AppSettings["CommunicationAttachment"] + objCA.strAttachment;
                    WebClient req = new WebClient();
                    HttpResponse response = HttpContext.Current.Response;
                    response.Clear();
                    response.ClearContent();
                    response.ClearHeaders();
                    response.Buffer = true;
                    response.AddHeader("Content-Disposition", "attachment;filename=\"" + Server.MapPath(strURL) + "\"");
                    byte[] data = req.DownloadData(Server.MapPath(strURL));
                    response.BinaryWrite(data);

No comments:

Post a Comment