In my MVC application, I recently have configured a page to allow an arbitrary file type to be uploaded(with certain restrictions that dont apply to this question).
You would return a FileContentResult.
In you controller, something like this:
byte[] data = MyDataContext.DocumentTable.First(p => p.DocumentUID == id);
return File(data, "text/plain", "myfile.txt");
In addition to the extension of the file, you need to specify a name for it as well. The 2nd parameter is the MIME type. This is important for some browsers (like FireFox) to determine which application to open your file with. Firefox will prefer the MIME type over the extension.