【发布时间】:2017-02-17 06:40:04
【问题描述】:
我的 REST API 以字节为单位返回 PDF 文档,我需要调用该 API 并在 ASP 页面上显示 PDF 文档以供用户预览。
我试过了
Response.Write HttpReq.responseBody
但它在页面上写了一些不可读的文本。 httpReq 是我调用 REST API 的对象。
REST API 的响应:
Request.CreateResponse(HttpStatusCode.OK, pdfStream, MediaTypeHeaderValue.Parse("application/pdf"))
【问题讨论】:
-
那是因为
Response.Write()将当前CodePage中的文本写回浏览器,如果要发回二进制数据使用Response.BinaryWrite()。
标签: vb.net asp.net-web-api vbscript asp-classic