title: How to pass image to Eval method from handler.ashx to imageurl?
body: <p>I want to retrieve image from database and display in an aspx page. I use Linq to SQL. And a Generic handler.</p>
  
  <p>Handler2.ashx code:</p>
  
  <pre><code>public void ProcessRequest(HttpContext context)
  {
      if (context.Request.QueryString["id"] != null)
      {
          int id;
          string sid = context.Request.QueryString["id"];
          if (int.TryParse(sid, out id))
          {
              Stream strm = getImage(id);
              byte[] buffer = new byte[4096];
              int i = strm.Read(buffer, 0, 4096);
              while (i &gt; 0)
              {
                  context.Response.OutputStream.Write(buffer, 0, 4096);
                  i = strm.Read(buffer, 0, 4096);
              }
          }
          else
          {
              //
          }
  
      }
  }
  
  
  public Stream getImage(int id)
  {
      using (DummyDBEntities cntx = new DummyDBEntities())
      {
          var db = from c in cntx.Images
                      where c.imageId == id
                      select c.imageData;
          MemoryStream ms = new MemoryStream();
          byte[] byteArray = new byte[db.ToArray().Length];
          ms.Write(byteArray, 0, db.ToArray().Length);
  
          return new MemoryStream(byteArray);
  
      }
  }
  </code></pre>
  
  <p>And a button control in Default.aspx page when I click, redirects to handler1.ashx. Gets the id of image from database and supposed to Show it in Default.aspx asp:image control</p>
  
  <pre><code>protected void btnGetID_Click(object sender, EventArgs e)
  {
    int id=Convert.ToInt32(txtGetID.Text);
    Response.Redirect("Handler2.ashx?id="+id);
    Image1.ImageUrl = '&lt;%# "~/Handler2.ashx?id=" + Eval("imageData"); %&gt;';
  }
  </code></pre>
  
  <p>How do i supposed to write Eval method and the querystring to pass the image to imageurl?</p>
  
  <pre><code>Image1.ImageUrl = '&lt;%# "~/Handler2.ashx?id=" + Eval("imageData"); %&gt;';
  </code></pre>
  
  <p>Please help, thanks.</p>