download a exe file from my asp page

Jul 10 2015 5:38 AM
I have a asp web page with c# code ,i am trying to download an exe file but it download entire web page instead of exe plz help( i am starter)

my requirement : i want to download a exe file from my website using asp and c#

i am trying this code:
 
protected void btn_download_Click(object sender, EventArgs e)     {         string filename = "SherAcc.exe";         if (filename != "")         {             string path = Server.MapPath(filename);             System.IO.FileInfo file = new System.IO.FileInfo(path);             if (file.Exists)             {                 Response.Clear();                 Response.AddHeader("Content-Disposition", "attachment; SheraAcc=" + file.Name);                                 Response.AddHeader("Content-Length", file.Length.ToString());                   Response.ContentType = "Application/octet-stream";                 Response.WriteFile(file.FullName);                 Response.End();             }             else             {                 Response.Write("This file does not exist.");             }         }     }
 The output : downloading the page
note : exe file place in same location of the project no additional folder used

Answers (2)