为什么我的 IHttpHandler 没有被调用?

发布于 2024-08-04 08:26:21 字数 979 浏览 2 评论 0原文

我正在尝试让自定义处理程序适用于 ASP.NET 3.5 中的特定 URL(或一组 URL)。

该处理程序实际上并没有做任何重要的事情 - 它只是记录请求。如果有人认为相关,我可以发布代码,但我真的认为它根本没有被调用。 (特别是,对于正常异常,我会得到一个自定义错误页面并进行日志记录...这里我只是得到了普通的 IIS 404。)

这是 web.config 文件的相关部分:(

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

显然该部分还有其他内容,但我认为它不相关。)

在本地,在开发服务器下运行,它工作正常。在我的真实盒子上,我总是收到 404。网站目录本身下的所有内容都是相同的(通过 svn 复制)。其中包括包含 CSharpInDepth.dllbin 目录,我已验证该目录包含 CSharpInDepth.Wave.RobotHandler

我尝试获取 http://csharpindepth.com/foo.robot 并得到 404。

我'已经尝试过使用或不使用程序集名称、特定 URL 或通配符...没有任何效果。

我确信我刚刚在 IIS 配置中的某个地方错过了一些简单的标志,但如果我能找到它,我会感到震惊...

编辑:这是 IIS 版本 6。现在正在尝试将 *.robot 添加到 ISAPI 过滤器。 ..

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮年 2024-08-11 08:26:21

如果托管盒是集成管道中的 IIS7,则需要将其添加到配置的其他位中:

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

如果是 IIS6,则需要将 *.robots 映射到 ASP.NET ISAPI DLL。

(对于非 Skeets,您可以按如下方式执行此操作)

  1. 打开 IIS 管理。
  2. 右键单击
    您要配置的网站
    并选择属性
    上下文菜单。这将显示
    网站属性对话框。
  3. 选择
    主目录选项卡,然后单击
    配置按钮。这将
    显示应用程序
    配置对话框。
  4. 点击
    添加。
  5. 选择aspnet_isapi.dll
    从.NET框架目录,
    您想要映射的扩展名和
    要么是所有动词,要么只是那些动词
    你想要映射。
  6. 单击“确定”。

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.
酒中人 2024-08-11 08:26:21

Jon,

您必须配置 IIS 脚本映射才能将 *.robot 传递到 aspnet_isapi.dll。

Jon,

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文