【发布时间】:2016-03-01 01:32:34
【问题描述】:
我正在将旧应用程序从经典模式迁移到集成模式,之前注册的 http 处理程序不再工作。我已经将处理程序部分放在了他们应该去的 system.webServer 下,但没有骰子:
<system.webServer>
<handlers>
...
<add name="zip.ashx_*" path="zip.ashx" verb="*" type="ZipDownloadHandler, Assembly" preCondition="integratedMode,runtimeVersionv2.0" resourceType="Unspecified" />
<add name="file.ashx_*" path="file.ashx" verb="*" type="FileDownloadHandler, Assembly" preCondition="integratedMode,runtimeVersionv2.0" resourceType="Unspecified" />
<add name="stream.ashx_*" path="stream.ashx" verb="GET" type="StreamDownloadHandler, Assembly" preCondition="integratedMode,runtimeVersionv2.0" resourceType="Unspecified" />
</handlers>
...
</system.webServer>
但它们总是返回 404。配置转储来自
appcmd list config "Default Web Site/MyApp" -section:system.webServer/handlers
正确显示处理程序:
<system.webServer>
<handlers accessPolicy="Read, Script">
...
<add name="zip.ashx_*" path="zip.ashx" verb="*" type="ZipDownloadHandler, Assembly" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
<add name="file.ashx_*" path="file.ashx" verb="*" type="FileDownloadHandler, Assembly" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
<add name="stream.ashx_*" path="stream.ashx" verb="GET" type="StreamDownloadHandler, Assembly" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
...
如果我从 stream.ashx 切换到将处理程序路径注册为 stream.foo,我仍然得到 404,但错误页面不同。对于 stream.ashx,它看起来像 like this,对于 stream.foo,它看起来像 like this。
也许 stream.ashx 实际上触发了 *.ashx 处理程序,该处理程序然后查找名为 stream.ashx 的文件,但找不到。我真的不知道其他处理程序发生了什么,因为我的配置看起来是正确的。任何建议将不胜感激。
【问题讨论】:
-
您在 IIS 的事件查看器中看到什么了吗?
-
Windows 事件查看器中没有任何内容,inetpub 下的 IIS 日志仅记录 URL 和返回的 404。从 VS 启动的 IIS express 也会发生完全相同的行为,因此至少这是一致的。我现在已经通过每个处理程序的路由解决了这个问题,我从中手动返回一个 HttpHandler 的实例,但我仍然想知道这里发生了什么。
标签: asp.net httphandler ashx