经典到集成模式,http 处理程序未运行



我正在将旧应用程序从经典模式迁移到集成模式,以前注册的 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,它看起来像这样,对于stream.foo,它看起来像这样。

也许 stream.ashx 实际上触发了 *.ashx 处理程序,然后查找名为 stream.ashx 的文件,但找不到。我真的不知道另一个处理程序发生了什么,因为我的配置看起来是正确的。任何建议将不胜感激。

我从来没有让它工作过,所以我只是用路由处理程序替换了 web.config 中的模块注册:

RouteTable.Routes.Add("stream", new Route("stream", new RouteHandler(new StreamDownloadHandler())));
RouteTable.Routes.Add("file", new Route("file", new RouteHandler(new FileDownloadHandler())));
RouteTable.Routes.Add("zip", new Route("zip", new RouteHandler(new ZipDownloadHandler())));

最新更新