I'm trying to use OWIN/Katana selfhosted console app with my generic ASHX handler, but just can't get it working. Is that even supported? I have it registered in app.config with path MyHandler.axd
as I'd do for an ASP.NET application (and where it works with this equivalent setup):
<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>
The handler implementation (that is not invoked):
namespace My.AssemblyName.Handlers
{
public class MyAsyncHandler : HttpTaskAsyncHandler
{
public override async Task ProcessRequestAsync(HttpContext context)
{
// code that is not hit
}
}
}
My Startup
class is implemented like this:
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);
}
}
And the application is invoked with
using (WebApp.Start<Startup>(url: baseAddress))
{
Console.ReadLine();
}
These are my installed NuGet packages:
System.Web.dll
EDIT: I see handlers are configured here with Nancy for the ASP.NET Host (Microsoft.Owin.Host.SystemWeb). How's that possible?
No, there's no support for running any System.Web components in Katana selfhost. Only the WebApi, SignalR, and other OWIN compatible frameworks are supported by Katana selfhost.