Anyone have any quick ways to send a file to a user? I can gen开发者_开发百科erate pdfs on the fly but need a way of passing it to the client then deleting the pdf.
try the FileResult - Response - well one of it's derived classes of course. You can often just write return File(...) (see Controller.File) and also look at ASP.NET MVC ploading and Downloading Files for some further examples and working code.
You can return File(stream, contentType)
or return File(filename, contentType)
to send the file to the user. If you can generate the PDF straight to a stream and avoid creating a file on disk then you're done. If it has to be created on disk then you should be able to delete the file in OnResultExecuted
.
精彩评论