I need to force the initiation of download of a .sql file, when user clicks a button in my ASP .NET (C#) based web application.
As in, when the button is clicked, a save as dialog should open at the client end...
How do I do this?
EDIT
This is the code I am using
string sql = "";
using (System.IO.StreamReader rdr = System.IO.File.OpenText(fileName))
{
sql = rdr.ReadToEnd();
}
Response.ContentType = "text/plain";
Response.AddHeader("Content-Disposition", "attachment; filename=Backup.sql");
Response.Write(sql);
Response.End();
This is the error that I'm getting...
alt text http://img40.imageshack.us/img40/2103/erroro.gif
What's wrong?