Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't my IHttpHandler being called?

I'm trying to get a custom handler to work for a specific URL (or set of URLs) in ASP.NET 3.5.

The handler doesn't actually do anything significant yet - it just logs the request. I can post the code if anyone things it's relevant, but I really don't think it's being called at all. (In particular, for normal exceptions I get a custom error page and logging... here I'm just getting the vanilla IIS 404.)

Here's the relevant bit of the web.config file:

<system.web>
  <httpHandlers>
    <add verb="GET,POST" path="*.robot" validate="false" 
         type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
  </httpHandlers>
</system.web>

(Obviously there's other stuff in that section too, but I don't think it's relevant.)

Locally, running under the dev server, it works fine. On my real box, I always get a 404. Everything under the web site directory itself is the same (replicated via svn). That includes the bin directory containing CSharpInDepth.dll, which I've verified contains CSharpInDepth.Wave.RobotHandler.

I try to fetch http://csharpindepth.com/foo.robot and just get a 404.

I've tried with and without the assembly name, specific URLs or wildcarded ones... nothing's working.

I'm sure I've just missed some simple flag somewhere in the IIS configuration, but I'm blowed if I can find it...

EDIT: It's IIS version 6. Attempting to add *.robot to the ISAPI filter now...

like image 413
Jon Skeet Avatar asked Sep 04 '09 19:09

Jon Skeet


2 Answers

Jon,

You'll have to configure the IIS script mappings to pass *.robot to aspnet_isapi.dll.

like image 38
John Saunders Avatar answered Nov 07 '22 02:11

John Saunders


Well if the hosting box is IIS7 in integrated pipeline you need to add it into the other bit of the config:

<system.webmodules>
  ....
  <modules>
    <add name="RobotHandler" type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
  </modules>
  ....
</system.webmodules>

If it's IIS6 then you'll need to map *.robots to the ASP.NET ISAPI DLL.

(For the non-Skeets you do this as follows)

  1. Open up IIS admin.
  2. Right click on the Web site you want to configure and select Properties form the context menu. This will display the Web Site Properties dialog.
  3. Select the Home Directory tab and click the Configuration button. This will display the Application Configuration dialog box.
  4. Click Add.
  5. Select the aspnet_isapi.dll from the .NET framework directory, the extension you want mapped and either All Verbs, or just the ones you want to map.
  6. Click ok.
like image 111
blowdart Avatar answered Nov 07 '22 03:11

blowdart