Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
661 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...