tags:

views:

59

answers:

1

I'm loading image from my database to temp file but my IIS can't see this file so I need to add it to my ISS somehow. I saw some way here Link So question is how to make and work with ImageHandler.dll Need I to create new dll application for it and then add to bin of my web app ?

+3  A: 

You can use generic handlers for it. Here is a sample:

<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.IO;
using System.Web;
using Deimand.Business;
using System.Configuration;

public class Handler : IHttpHandler
{
    public bool IsReusable
    { get{ return false; } }

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "image/jpeg";
        if (context.Request.QueryString["imageId"] != null)
        {
           byte[] imageContent = GetImageFromDataBase(context.Request.QueryString["imageId"]);
           context.Response.OutputStream.Write(imageContent, 0, imageContent.Length);
        }
    }
}
iburlakov
thank you very much
nCdy