How to download a text file with download prompt from aspx page

Suresh.mekkattil
Posted by Suresh.mekkattil under ASP.NET category on | Points: 40 | Views : 2710
            string path = MapPath("SampleFile.txt");
string name = Path.GetFileName(path);

Response.AppendHeader("content-disposition", "attachment; filename=" + name);
Response.ContentType = "text/plain";
Response.WriteFile(path);
Response.End();

Comments or Responses

Login to post response