开发者

Rendering memory stream to browser in VB.NET

开发者 https://www.devze.com 2023-01-02 21:25 出处:网络
In VB.NET, how can I write a memory stream to browser. My memory stream object has data to build a PDF file. Now I want it to be ren开发者_开发知识库dered on browser. How to do that?You could try some

In VB.NET, how can I write a memory stream to browser. My memory stream object has data to build a PDF file. Now I want it to be ren开发者_开发知识库dered on browser. How to do that?


You could try something like:

Dim stream As MemoryStream = GetMemoryStream()
Response.Clear()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition", "attachment; filename=yourfile.pdf")
Response.Write(stream.ToArray())
Response.End()

I have not tested the code nor am I sure of the mime type, but this should get you started.

0

精彩评论

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