Search code examples
asp.netweb-confighttphandler

Custom HTTP handler configuration fail


I am developing an ASP .Net website. I have created a custom HTTP handler to respond to requests aiming resources with .videoImage extension.
Here are the first lines of the file corresponding to my handler :

<%@ WebHandler Language="C#" Class="CompleteSubtitles.VideoImage" %>

using System;
using System.Web;
using System.IO;
using SubtitleSounds.DataManagement;

namespace CompleteSubtitles
{
    public class VideoImage : IHttpHandler
    {
        ...
    }
}

The handler file is located in a subfolder of the website root folder.
I have configured my handler in my website root web.config file as follows :

<configuration>
    <system.web>
        ...

        <httpHandlers>
          <add verb="*" path="*.videoImage" type="CompleteSubtitles.VideoImage" />
        </httpHandlers>
    </system.web>
</configuration>

I have got an ASP .Net error message when loading a page informing me that the loading of CompleteSubtitles.VideoImage type failed.
Does anyone know why ?
Any help will be greatly appreciated.


Solution

  • Here is how I have solved my problem :
    I have created a class representing my handler in my App_Code folder.
    My handler file's extension is ".cs" and not ".ashx".
    The declaration of my handler in my web.config is :

    <httpHandlers>
      <add verb="*" path="*.videoImage" type="CompleteSubtitles.VideoImageHandler" />
    </httpHandlers>