Skip to content

Instantly share code, notes, and snippets.

@weslley39
Created February 27, 2014 15:31
Show Gist options
  • Save weslley39/9252363 to your computer and use it in GitHub Desktop.
Save weslley39/9252363 to your computer and use it in GitHub Desktop.
Forcing download of a type in Asp Mvc C#
var bytes = Encoding.UTF8.GetBytes(sb.ToString());
Stream stream = new MemoryStream(bytes);
stream.Flush();
stream.Position = 0;
Response.ContentType = "text/plain";
Response.AppendHeader("content-disposition", "attachment;filename=exportacao");
return new FileStreamResult(stream, "text/plain");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment