Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamic image (from db) using Generic Handler
    primarykey
    data
    text
    <p>I'm trying to using a Generic Handler to retrieve and display images that are stored in a database.</p> <p>But its just not working. Ive tried verious of the code below, but I cant seem to get it to work.</p> <p>Can anyonne spot what I am doing wrong, or have some suggestions?</p> <pre><code>&lt;%@ WebHandler Language="C#" Class="IconsDb" %&gt; using System; using System.Web; using System.Linq; using System.Data.Entity; public class IconsDb : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); Int32 iconId; if (context.Request.QueryString["id"] != null) iconId = Convert.ToInt32(context.Request.QueryString["id"]); else throw new ArgumentException("No parameter specified"); context.Response.ContentType = "image/gif"; //System.IO.Stream strm = ShowEmpImage(iconId); var db = new UdINaturen.UdINaturenContext(); var GetIcon = (from i in db.subcategoryicons where i.id == iconId select i.picture).FirstOrDefault(); object img = GetIcon; System.IO.MemoryStream memStream= new System.IO.MemoryStream((byte[])Convert.FromBase64String(GetIcon)); System.Drawing.Bitmap bitImage=new System.Drawing.Bitmap((System.Drawing.Bitmap)System.Drawing.Image.FromStream(memStream)); byte[] buffer = memStream.ToArray(); context.Response.ContentType = "image/gif"; //context.Response.OutputStream.Write(buffer, 0, buffer.Length); //context.Response.WriteFile(); context.Response.BinaryWrite(buffer); //context.Response.Flush(); } public bool IsReusable { get { return true; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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