Click here to Skip to main content
15,115,146 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello.

I have made a class for the Download statement as below, but when download completes the downloaded file is not working and is corrupted, what is the problem in this class?

C#
public class DownLoad
{
    public static void FileDownLoad(string URL)
    {
        WebClient Request = new WebClient();
        HttpResponse Response = HttpContext.Current.Response;
        Response.Clear();
        Response.ClearContent();
        Response.ClearHeaders();
        Response.Buffer = true;
        Response.AddHeader("Content-Disposition", "attachment;filename=\"" +URL +"\"");
        byte[] data = Request.DownloadData(URL);
        Response.BinaryWrite(data);
        Response.End();
    }
}
Posted
Comments
Zoltán Zörgő 7-Sep-13 5:51am
   
So you want to download a file and send it as response to at the same time?
mohammad ehsan 7-Sep-13 5:54am
   
yes

1 solution

Making a proxy like thing is a little more difficult, but not too much.
I suggest you start from this implementation: http://kiwigis.blogspot.hu/2011/08/how-to-create-simple-proxy-in-aspnet.html[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900