0

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.

1
  • 1
    in the 'type' attribute, you need to give Assembly name and then type name probably like this for your case type="CompleteSubtitles, CompleteSubtitles.VideoImage" Commented Feb 6, 2013 at 11:29

3 Answers 3

1

Whitout the exact error message I can't be sure, but when from my experience with handlers and Web Forms, this works:

  • Your Handler can't be a simple VB/CS file, even if you place it on APP_CODE folder (never worked with me). You need place in a DLL, I always use a separate Class Library for that.

  • If the host uses IIS 7, system.web/httpHandlers don't work, you need to add system.webServer. I keep both just in case. Here is a sample (bNet.Ferramentas is my DLL file):

>

<system.web>
    <httpHandlers>
        <add verb="*" path="sitemap.ashx" type="bNet.Ferramentas.SiteMapHandler, bNet.Ferramentas" />
    </httpHandlers>
</system.web >


<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
        <add verb="*" name="bnetSitemap" path="sitemap.ashx" type="bNet.Ferramentas.SiteMapHandler, bNet.Ferramentas"/>
    </handlers>
</system.webServer>

Sign up to request clarification or add additional context in comments.

Comments

1

you have to specify the full name of the class (HttpHanlder) as follows:

 <configuration> 
 <system.webServer>
 <handlers> 
    <add verb="*" path="*.sample" name="HelloWorldHandler" type="HelloWorldHandler"/>
 </handlers>
 </system.webServer>
 </configuration>

For more click here

Hope it will help.

Comments

0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.