2014-09-19 54 views
0

我有一个web服务,在这种情况下,我有一个以base64编码的图像,我想返回为http响应正文中包含的字符串。我尝试添加以下标题:返回Base64编码图像作为C#中的HTTP响应

内容类型:图像/ GIF

内容传输编码:的base64

的浏览器不解释的图像虽然正确。

是否有可能将base64编码图像作为字符串返回到主体并让浏览器将其解释为图像?

回答

0
Response.ContentType = attachmentRow["ContentType"].ToString(); 
Response.BinaryWrite((byte[])attachmentRow["Data"]);     
Response.End(); 

这应该够了。

attachmentRow["ContentType"] = "image/gif"; 
attachmentRow["Data"] field of type image(byte array) in your AttachmentTable. 
0

HTTP中没有Content-Transfer-Encoding。只需返回二进制数据。