Blog Stats
  • Posts - 35
  • Articles - 0
  • Comments - 7
  • Trackbacks - 2

 

Force a page to download a file c# asp.net

string Id= "0";
try
{
this.EnableViewState = false;
Response.ContentType = "text/.txt";
string Filename = System.Web.HttpContext.Current.Server.MapPath("txt/");
Filename = Filename + Id + ".txt";
Response.WriteFile(Filename);
// Response.Write("string");
string strFilename = Id + ".txt";
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment; filename=" + ID+".txt");
}
catch (Exception ex) { Response.Write(ex.ToString()); }
Response.End();
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

 

 

Copyright © Sharvan Dhaka