Download file using filestreamresult






















It would be nice to be able to download the data as a tab-delimited file or something like that, so I can just open it with my favorite text editor and use the search functionality. To make a stream from stuff you have in memory, you use a MemoryStream. Basically, its just an array of bytes. You can write bytes directly to it with the Write method, or you can use a StreamWriter to make it easier to write basic types:. So you can easily put your data in to a stream, but then you need to return it in the right way from the WebAPI.

Related Articles. Add Comments. Thank you for the feedback. The comment is now awaiting moderation. You will be notified via email when the author replies to your comment. Please select a comment to reply. You can add your comment about this article using the form below. Make sure you provide a valid email address else you won't be notified when the author replies to your comment Please note that all comments are moderated and will be deleted if they are Not relavant to the article Spam Advertising campaigns or links to other sites Abusive content.

Please do not post code, scripts or snippets. Required Invalid Email Address. Security code:. Required Invalid security code. Ref v5. Ref v6. Is this page helpful? Please rate your experience Yes No. Any additional feedback? In this article. FileStreamResult Stream, String. Gets the Content-Type header for the response. Example File: BarcodesController.

MakeBarcodeImage id, 2, false ; img. Save ms, ImageFormat. Png ; ms. File: ImageController. File: ReportingController. ByUserReport from, to. AddDays 1 ; report. Write stream ; stream. ToString "yyyyMMdd" , to. File: DocumentSessionExtensions. GetAttachment key ; if attachment! Data , attachment. File: FileHandler. FileName; if File. File: FilesController. FileStream filePath, System. Open , GetMimeType filePath ; result. File: ImageResult. The context information includes the controller, HTTP content, request context, and route data.

Stream, resolveResult. MimeType ; fileStreamResult. IndexOfAny System. Combine Properties.



0コメント

  • 1000 / 1000