I'm trying to get a custom handler to work for a specific URL (or set of URLs) in ASP.NET 3.5.
我正在尝试使用自定义处理程序来处理ASP.NET 3.5中的特定URL(或一组URL)。
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.)
处理程序实际上并没有做任何重要的事情 - 它只是记录请求。我可以发布代码,如果有任何相关的东西,但我真的不认为它被调用。 (特别是,对于正常的异常,我得到一个自定义错误页面并记录...这里我只是得到了香草IIS 404.)
Here's the relevant bit of the web.config
file:
这是web.config文件的相关位:
<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
.
在本地,在开发服务器下运行,它工作正常。在我的真实盒子上,我总是得到一个404.网站目录下的一切都是一样的(通过svn复制)。这包括包含CSharpInDepth.dll的bin目录,我已经验证它包含CSharpInDepth.Wave.RobotHandler。
I try to fetch http://csharpindepth.com/foo.robot and just get a 404.
我尝试获取http://csharpindepth.com/foo.robot并获得404。
I've tried with and without the assembly name, specific URLs or wildcarded ones... nothing's working.
我尝试过使用和不使用程序集名称,特定URL或通配符......没有任何工作。
I'm sure I've just missed some simple flag somewhere in the IIS configuration, but I'm blowed if I can find it...
我确定我在IIS配置中的某个地方错过了一些简单的标志,但是如果我能找到它我就会被炸毁...
EDIT: It's IIS version 6. Attempting to add *.robot to the ISAPI filter now...
编辑:这是IIS版本6.现在尝试将* .robot添加到ISAPI过滤器...
2 个解决方案
#1
32
Well if the hosting box is IIS7 in integrated pipeline you need to add it into the other bit of the config:
好吧,如果主机盒是集成管道中的IIS7,你需要将它添加到配置的另一位:
<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.
如果它是IIS6,那么你需要将* .robots映射到ASP.NET ISAPI DLL。
(For the non-Skeets you do this as follows)
(对于非Skeets,你这样做如下)
- Open up IIS admin.
- 打开IIS管理员。
- 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.
- 右键单击要配置的网站,然后从上下文菜单中选择“属性”。这将显示“网站属性”对话框。
- Select the Home Directory tab and click the Configuration button. This will display the Application Configuration dialog box.
- 选择“主目录”选项卡,然后单击“配置”按钮。这将显示“应用程序配置”对话框。
- Click Add.
- 单击添加。
- 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.
- 从.NET框架目录中选择aspnet_isapi.dll,您要映射的扩展名为All Verbs,或者只是您要映射的扩展名。
- Click ok.
- 点击确定。
#2
9
Jon,
乔恩,
You'll have to configure the IIS script mappings to pass *.robot to aspnet_isapi.dll.
您必须配置IIS脚本映射以将* .robot传递给aspnet_isapi.dll。
#1
32
Well if the hosting box is IIS7 in integrated pipeline you need to add it into the other bit of the config:
好吧,如果主机盒是集成管道中的IIS7,你需要将它添加到配置的另一位:
<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.
如果它是IIS6,那么你需要将* .robots映射到ASP.NET ISAPI DLL。
(For the non-Skeets you do this as follows)
(对于非Skeets,你这样做如下)
- Open up IIS admin.
- 打开IIS管理员。
- 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.
- 右键单击要配置的网站,然后从上下文菜单中选择“属性”。这将显示“网站属性”对话框。
- Select the Home Directory tab and click the Configuration button. This will display the Application Configuration dialog box.
- 选择“主目录”选项卡,然后单击“配置”按钮。这将显示“应用程序配置”对话框。
- Click Add.
- 单击添加。
- 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.
- 从.NET框架目录中选择aspnet_isapi.dll,您要映射的扩展名为All Verbs,或者只是您要映射的扩展名。
- Click ok.
- 点击确定。
#2
9
Jon,
乔恩,
You'll have to configure the IIS script mappings to pass *.robot to aspnet_isapi.dll.
您必须配置IIS脚本映射以将* .robot传递给aspnet_isapi.dll。