Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing a handler to render an image from a blob on an ASP.NET page. I can't get it
    primarykey
    data
    text
    <p>I'm working on a simple image tagging and searching app. I've got my images uploading to the DB, the tags being applied, but am failing when I pull them back - the images don't render.</p> <p>I found <a href="https://stackoverflow.com/questions/21877/dynamically-rendering-aspimage-from-blob-entry-in-asp-net">this</a> here on SO, but I'm not able to get it working.</p> <p>I think I am perhaps misunderstanding handlers.</p> <p>In short, in the code behind, I'm creating an ASP:Image, setting its imageurl to the handler with the id of the photo, and then adding that control to an ASP:Placeholder.</p> <p>When the page renders, I get, in IE, that little red x no image thing, and in FF, nothing.</p> <p>One thing that gets me thinking I'm missing something is that a breakpoint in my handler code is never hit. So it's even getting executed. Right?</p> <p>Anyone know what I'm doing wrong here? Thanks.</p> <p>Here's my handler</p> <pre><code>Imports aapeClsLib Imports System.Web Imports System.Web.Services Public Class photos Implements System.Web.IHttpHandler Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim img As Byte() = getImage(context.Request.QueryString("ID")) context.Response.Clear() context.Response.ContentType = "image/jpeg" context.Response.BinaryWrite(img) context.Response.End() End Sub ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property Private Function getImage(ByVal id As String) As Byte() Dim img As Byte() Dim strSql As String = "select ph_photo from photos where ph_id = " &amp; id Dim dt As DataTable = sqLiteData.getDataTable(strSql) img = CType(dt.Rows(0)(0), Byte()) Return img End Function End Class </code></pre> <p>and where I'm sticking it in my placeholder</p> <pre><code>Private Sub insertPhotos(ByVal dt As DataTable) For Each row As DataRow In dt.Rows Dim img As New Image img.ImageUrl = "photos.ashx?ID=" &amp; row(0) PlaceHolder1.Controls.Add(img) Next End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload