OWIN/Katana 未调用自托管通用处理程序 (ashx)

OWIN/Katana selfhost generic handler (ashx) not invoked

我正在尝试将 OWIN/Katana 自托管控制台应用程序与我的通用 ASHX 处理程序一起使用,但就是无法正常工作。甚至支持吗?我在 app.config 中使用路径 MyHandler.axd 注册了它,就像我为 ASP.NET 应用程序所做的那样(以及它使用此等效设置的地方):

 <system.webServer>
    <handlers>
        <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
        <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
        <add name="MyHandler" path="MyHandler.axd" verb="*" type="My.AssemblyName.Handlers.MyAsyncHandler, My.AssemblyName, Culture=neutral" />
    </handlers>
</system.webServer>

处理程序实现(未调用):

 namespace My.AssemblyName.Handlers
 {
     public class MyAsyncHandler : HttpTaskAsyncHandler
     {
        public override async Task ProcessRequestAsync(HttpContext context)
        {
            // code that is not hit
        }
    }
}

我的Startupclass是这样实现的:

public class Startup
{
    public void Configuration(IAppBuilder appBuilder)
    {
        HttpConfiguration config = new HttpConfiguration();
        config.Routes.IgnoreRoute("MyHandler.axd", "{resource}.axd/{*pathInfo}");
        config.Routes.IgnoreRoute("MyHandler.ashx", "{resource}.ashx/{*pathInfo}");
        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new {id = RouteParameter.Optional}
            );

        appBuilder.UseWebApi(config);
    }
}

应用程序被调用

using (WebApp.Start<Startup>(url: baseAddress))
{
    Console.ReadLine();
}

这些是我安装的 NuGet 包:

编辑:我看到为ASP.NET主机(Microsoft.Owin.Host.SystemWeb)配置了处理程序here with Nancy。怎么可能?

不,Katana selfhost 不支持 运行 任何 System.Web 组件。 Katana selfhost 仅支持 WebApi、SignalR 和其他 OWIN 兼容框架。