开发者

Sending files to users

开发者 https://www.devze.com 2023-03-28 23:24 出处:网络
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 - wel

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消