【发布时间】:2015-02-02 13:13:14
【问题描述】:
我正在尝试使用通用处理程序显示 base64,但没有成功。这是我的通用处理程序代码:
public class UserProfilePhoto : IHttpHandler, IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
try
{
if (UserSession.Get().UserPhoto == null)
{
context.Response.ContentType = "image/png";
context.Response.WriteFile("~/assets/img/avatar.png");
}
else
{
context.Response.ContentType = UserSession.Get().UserPhoto.Substring(0, UserSession.Get().UserPhoto.IndexOf(","));
context.Response.Write(UserSession.Get().UserPhoto);
}
}
catch (Exception ex)
{
throw ex;
}
}
public bool IsReusable
{
get
{
return true;
}
}
}
在视图页面上调用如下:
<img alt="Photo" ng-src="UserProfilePhoto.ashx" />
它不会改变 img 标签的 src。我不知道出了什么问题。帮助。 Here is the base64 string which I am getting from database.
【问题讨论】:
-
@malkam 我需要渲染一个以字符串形式存储的 base64 图像。
标签: c# asp.net-mvc base64 ashx