asp.net - Missing Loading Image From Database Use Handler.ashx
问题描述
I use the Handler.ashx to get and display images from database. But they didn't all display, only 100% after request few times. I don't know how to solve.
Handler.ashx code:
public void ProcessRequest(HttpContext context)
{
if (context.Request.QueryString["ImageID"] != null)
{
Byte[] bytes;
string _strModelCode = context.Request.QueryString["ImageID"];
try
{
bytes = ModelBLL.GetImage(_strModelCode);
}
catch
{
bytes = null;
}
context.Response.ContentType = "Image/jpg";
if (bytes != null)
{
try
{
context.Response.BinaryWrite(bytes);
}
catch { }
}
context.Response.End();
return;
}
}
Image Loading Code:
foreach (GridViewRow _row in gridDispaly.Rows)
{
Image img = (Image)_row.FindControl("imgModel");
img.ImageUrl = "../Handler.ashx?ImageID=" + _row.Cells[0].Text;
}
Thank you!
解决方案
推荐阅读
- php - 使用波斯字符导致mysql表的每个字段插入值null
- python - Shell 命令 - 延迟 stdout 日志,因为在命令执行时路径不存在
- reactjs - React hooks:可激活状态模式
- python - SQLAlchemy AmbiguousForeignKeysError
- angular - 无法将来自 Web api 的数据绑定到 Angular 中的选择选项
- python - 类中有两个版本的 self 对象,这怎么可能?
- javascript - firebase 查询无法获取数据
- javascript - TypeError:无法读取 Angularjs 中未定义的属性“0”
- javascript - npm 的 `debug` 包:显示来自 2 个包的日志
- java - 使用 Bing 和 Java 进行地理定位