Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am using asp.net 2010. i have upload image, doc.,any type on cdn server .
now i want to download from cdn in such way as when i click on download button then any popup should be open for selectiong location ( where you want to save it.) then this file should be downloaded on that choosen location. any can help me
Thanks & regards
Posted

C#
string result = Path.GetFileName(path);
       //Response.ContentType = "Document/Docx";
       Response.ContentType = "application/vnd.ms-word";

       Response.AppendHeader("Content-Disposition", "inline; filename=" + result);
       Response.TransmitFile(Server.MapPath(path));
       Response.End();
 
Share this answer
 
Comments
gauravrawat 9-Sep-11 8:47am    
this code not working .
i an downloading from this path:
http://cdn.stukcdn.net/z5b6p5y7/cds/LIPC/Docs/20110907015031-ff81f04c-b576-4e15-b899-9396eea45571.jpg
this give erron on Response.TransmitFile(Server.MapPath(path));
(Exception is"this is not valid virtual path ")
Preferences oRefrence = new Preferences("UPLOADFOLDERTEMP"); //Class
string filename = oRefrence.VALUE + e.CommandName;
string fileName = string.Empty;
fileName = e.CommandName.Substring(e.CommandName.IndexOf("-_-") + 3);
FileInfo fileinfo = new FileInfo(filename);

if (fileinfo.Exists)
{
Response.Clear();
Response.Charset = "";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.AddHeader("Content-Length", fileinfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.TransmitFile(fileinfo.FullName);
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();

}
 
Share this answer
 
Comments
Member 10437096 3-Apr-14 13:49pm    
this is right code
download(file name);
you can download any file.
 
Share this answer
 

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