我将旧应用程序从经典模式迁移到集成模式,之前注册的http处理程序不再有效。我已将处理程序部分放在system.webServer下,他们应该去哪里,但没有骰子:
<system.webServer>
<handlers>
...
<add name="zip.ashx_*" path="zip.ashx" verb="*" type="SpringAir.Web.ZipDownloadHandler, SpecAndQuote" preCondition="integratedMode,runtimeVersionv2.0" resourceType="Unspecified" />
<add name="file.ashx_*" path="file.ashx" verb="*" type="SpringAir.Web.FileDownloadHandler, SpecAndQuote" preCondition="integratedMode,runtimeVersionv2.0" resourceType="Unspecified" />
<add name="stream.ashx_*" path="stream.ashx" verb="GET" type="SpringAir.Web.StreamDownloadHandler, SpecAndQuote" 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="SpringAir.Web.ZipDownloadHandler, SpecAndQuote" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
<add name="file.ashx_*" path="file.ashx" verb="*" type="SpringAir.Web.FileDownloadHandler, SpecAndQuote" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" />
<add name="stream.ashx_*" path="stream.ashx" verb="GET" type="SpringAir.Web.StreamDownloadHandler, SpecAndQuote" 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的文件,但找不到该文件。我真的不知道与其他处理程序发生了什么,因为我的配置看起来是正确的。任何建议将不胜感激。
答案 0 :(得分:0)
我从来没有让它工作,所以我只是用路由处理程序替换了web.config中的模块注册:
RouteTable.Routes.Add("stream", new Route("stream", new SpringAir.Web.RouteHandler(new SpringAir.Web.StreamDownloadHandler())));
RouteTable.Routes.Add("file", new Route("file", new SpringAir.Web.RouteHandler(new SpringAir.Web.FileDownloadHandler())));
RouteTable.Routes.Add("zip", new Route("zip", new SpringAir.Web.RouteHandler(new SpringAir.Web.ZipDownloadHandler())));