title: How to register ImageHandler in web.config
body: <p>I have written the following handler class which is used to read images from database and show them in my web page :</p>
  
  <pre><code>&lt;%@ WebHandler Language="C#" Class="Handler" %&gt;
  
  using System;
  using System.Configuration;
  using System.Data.SqlClient;
  using System.Web;
  
  public class Handler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
  {
  
      SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["IranQRDBConnectionString"].ConnectionString);
      public void ProcessRequest(HttpContext context)
      {
          try
          {
              string TableName = context.Session["TableToQuery"].ToString();
              string ID = context.Session["ID"].ToString();
  
              SqlCommand comm = new SqlCommand("SELECT * FROM " + TableName + " WHERE ID=" + ID, conn);
  
              conn.Open();
              SqlDataReader dr = comm.ExecuteReader();
              dr.Read();
              context.Response.ContentType = "image/jpeg";
              context.Response.BinaryWrite((byte[])dr["Image"]);
              conn.Close();
  
          }
          catch
          {
              SqlCommand comm = new SqlCommand("SELECT * FROM DefaultImage WHERE ID=1", conn);
  
              conn.Open();
              SqlDataReader dr = comm.ExecuteReader();
              dr.Read();
              context.Response.ContentType = "image/jpeg";
              context.Response.BinaryWrite((byte[])dr["Image"]);
              conn.Close();
          }
      }
  
      public bool IsReusable
      {
          get
          {
              return false;
          }
      }
  
  }
  </code></pre>
  
  <p>This class works fine on my local ! I have uploaded my website and when I query my database all data is returned to my web page except the image is not shown in the image control. I have searched the web and I found out that I should register my handler in the <code>web.config</code> file and also IIS version is 7 on the host and It's running in integrated mode ! So I know that I should register that handler in <code>&lt;System.webserver&gt;&lt;Handlers&gt;</code>  part of the <code>web.config</code> . </p>
  
  <p>For more detail I added the handler class to my project root directory and not in the <code>App_Code</code> directory ! And I have uploaded the website as precompiled website and I have the precompiled <code>Handler.ashx</code> in my root directory and I have <code>App_Web_handler.ashx.cdcab7d2.dll</code> file in my <code>App_Code</code> .</p>
  
  <p>I also have added :</p>
  
  <pre><code>&lt;add name="ImageHandler" verb="*" path="*.jpg" type="Handler" /&gt;
  </code></pre>
  
  <p>in my <code>web.config</code> file but it still does not work :( </p>
  
  <p>Could any one help please me find the correct registration ?</p>