我收到一个 Base64 字符串,它实际上是 PDF 文件的字符串表示形式。我想用 Response.Write 写这个字符串,但不把它转换回它的二进制表示。
我试过这个:
var base64string = "...";
Response.Write(base64String);
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Transfer-Encoding", "base64");
浏览器无法将内容识别为 base64 编码的 PDF 文件。我怎样才能解决这个问题?
编辑:这是回应
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/pdf; charset=utf-8
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
Content-Transfer-Encoding: base64
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 11 Apr 2012 11:00:04 GMT
Content-Length: 107304
JVBERi0xLjQKJeLjz9MKMSA... more content here