Created
June 27, 2013 14:13
-
-
Save venblee/5876745 to your computer and use it in GitHub Desktop.
Returning a File from MVC Controller.
Makes user you use <a> </a>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Download() | |
{ | |
// Get the file content as string | |
string fileContent = GetCSVFileContent(); | |
// Get the bytes for the dynamic string content | |
var byteArray = Encoding.ASCII.GetBytes(fileContent); | |
string fileName = "Download File in ASP.NET MVC with dynamic content.csv"; | |
return File(byteArray, "text/csv", fileName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment