ASP.Net Web Forms: How to download a file? How to save string to a file?

 private void SaveFile(string featureKey)

{
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment;                                     filename=FeatureKey.txt");

if (Response.IsClientConnected)
{
var buffer = Encoding.ASCII.GetBytes(featureKey);
var length = featureKey.Length;
Response.OutputStream.Write(buffer, 0, length);
}

Response.Flush();
Response.End();

}

Comments

Popular posts from this blog

WPF How to Dispose ViewModel when the associated UserControl (Not Window) closes?

C# How to unit test Dispatcher

WPF: How to Deep Copy WPF object (e.g. UIElement) ?