views:

569

answers:

2

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...

+3  A: 

Jon,

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

John Saunders
Many thanks - done :)
Jon Skeet
+9  A: 

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.
blowdart
Bah - after experimenting, I've just written that set of instructions up in the question. Will edit them out again :)
Jon Skeet
Aargh... it worked for my foo.robot example, but now I need to serve just "jsonrpc" (full URL - http://csharpindepth.com/Wave/_wave/robot/jsonrpc). Obviously that doesn't have an "extension" per se... any clues?
Jon Skeet
You don't have a hope. Directories are served by IIS, not ASP.NET. You could fake it by creating it, and putting a default.aspx file in there, or of course ISAPI rewriters which map it to a real aspx, at which point ASP.NET will kick in
blowdart
@blowdart: So how does ASP.NET MVC do its mappings? Does that use a rewriter? I'll try the default.aspx file...
Jon Skeet
(I've done the re-writter trick before for this).
blowdart
@blowdart: Bah. It serves a redirect. That'll be no good. Hmm. Might whinge at the Wave team and ask them to reconsider their URL choice :)
Jon Skeet
Hmm ASP.NET MVC maps everything (on IIS6) if you want it to work right. Mind you not sure about how it copes with virtual directories - there's a virtual path provider which might do it, http://support.microsoft.com/kb/910441
blowdart
@blowdart: For the moment, I've changed my AppEngine Wave Robot proxy to add ".robot" onto the end if the path ends with "jsonrpc". Ugly, but it'll do for now :)
Jon Skeet