IIS 6 ASP.NET 处理程序 404 错误
我有一个在 Windows Server 2003 (x86) 上运行的 IIS6,并编写了一个自定义处理程序(不是 404 错误的处理程序)。
当我尝试通过在浏览器中打开 http://localhost/Priority1.Sync/Transfer.p1s 来访问处理程序时,我收到错误 404(日志文件中为 404 0)。 Web 应用程序中的其他页面可以正常工作,例如 http://localhost/priority1.sync/syncservice.asmx
该处理程序在我的 IIS7 开发机器上运行良好。
web.config 设置如下:
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*.p1s" type="MCS.Priority1.Sync.WebServices.TransferHandler, SyncService" />
</httpHandlers>
我已为“*.p1s”设置了应用程序扩展名(默认网站>属性>主目录>配置>映射>添加)。
我还缺少其他东西吗?
谢谢, 安迪
I have an IIS6 running on Windows Server 2003 (x86) and have written a custom handler (Not a handler for 404 errors).
When I try to access the handler by opening in a browser http://localhost/Priority1.Sync/Transfer.p1s, I get error 404 (404 0 in log file). Other pages in the web application work, e.g. http://localhost/priority1.sync/syncservice.asmx
The handler works fine on my IIS7 dev machine.
web.config is setup as follows:
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*.p1s" type="MCS.Priority1.Sync.WebServices.TransferHandler, SyncService" />
</httpHandlers>
I have set an application extension for "*.p1s" (Default Web Site>Properties>Home Directory>Configuration>Mappings>Add).
Am I missing something else?
Thanks,
Andy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否在自定义处理程序 IIS 配置中选中了“验证该文件存在”选项?
IIS6 期望物理文件默认存在。如果没有,它根本不会将请求传递给您的处理程序。您需要禁用此检查,以便它将按预期将请求发送到您的处理程序。
Do you have the "Verify that file exists" option in your custom handler IIS configuration checked or not?
IIS6 expects a physical file to exist by default. If there isn't one, it won't pass the request on to your handler at all. You need to disable this check, so it will send the request to your handler as expected.
IIS6 和 IIS7 是根本不同的野兽。 IIS7 的托管管道意味着每个请求都会到达您注册的处理程序,在 IIS6 中,仅处理映射到 ASPNET_ISAPI.DLL 的内容(通常是 *.aspx 和 *.ashx 以及其他默认 ASP.NET 扩展)。
您可以通过使用该项目的开发应用程序池的“经典”管道,使 IIS7 开发盒以这种方式运行。
使其按预期方式工作的另一个技巧是将 404 错误映射到 ASP.NET 页面,然后您至少可以进入处理程序。
老实说,我希望将生产升级到 IIS7,因为它的功能要强大得多,甚至一点也不有趣。
IIS6 and IIS7 are fundamentally different beasts. IIS7's managed pipeline means every request hits your registered handlers, in IIS6 only things mapped to ASPNET_ISAPI.DLL (typically *.aspx and *.ashx and other default ASP.NET extensions) get processed.
You can make your IIS7 dev box behave this way by using the "classic" pipeline for your development app pool for this project.
Another trick to making it work how you expect is to map 404 errors to an ASP.NET page and then you can at least get into your handler.
In all honesty I would look towards upgrading production to IIS7 as it is so vastly more capable it isn't even funny.
如果您正在为 IIS 6 注册处理程序,请记住它们应该放置在
web.config 的
部分的
元素,而不是 IIS7 的
部分用途。If you are registering handlers for IIS 6 then do remember they should be placed in the
<httpHandlers>
element of<system.web>
section of the web.config not the<system.webServer>
section that IIS7 uses.