aspnet / AspNetKatana

Microsoft's OWIN implementation, the Katana project
Apache License 2.0
967 stars 333 forks source link

How does the OwinHost.SystemWeb regiester it's module and handler ? #473

Closed John0King closed 2 years ago

John0King commented 2 years ago

when use Owin , there no configuration in web.config, but how it regiester the OwinHttpModule and OwinHttpHandler ?

CZEMacLeod commented 2 years ago

See https://github.com/aspnet/AspNetKatana/blob/main/src/Microsoft.Owin.Host.SystemWeb/PreApplicationStart.cs Basically, the assembly has a PreApplicationStartMethod attribute defined that causes the IIS dotnet hosting runtime to execute the Initialize function which then registers the OwinHttpModule. I don't think the handler is registered as such - it is just setup as a route handler, same as MVC etc. based on the paths you map when you setup your owin app.

John0King commented 2 years ago

Thanks , I figured out the httpmodule registeration , but there is also a OwinHttpHandler.cs , and how it work or does it work at all ?

Tratcher commented 2 years ago

The handler is only used when manually registered. https://github.com/aspnet/AspNetKatana/blob/dbe159e43e2eee44f315f26268943e8ab5a4f60d/src/Microsoft.Owin.Host.SystemWeb/RouteCollectionExtensions.cs#L112-L117 https://github.com/aspnet/AspNetKatana/blob/dbe159e43e2eee44f315f26268943e8ab5a4f60d/src/Microsoft.Owin.Host.SystemWeb/OwinRouteHandler.cs#L62-L64

John0King commented 2 years ago

Thanks @Tratcher

Does that means the OwinRouteHandler is not been used normally (now all owin stuff handled by the OwinHttpModule)?

and Maybe it too late for the System.Web stuff. but I think we should add a doc/wiki about how owin startup ,

currently the doc only have a very short word about the startup , https://docs.microsoft.com/en-us/aspnet/aspnet/overview/owin-and-katana/owin-middleware-in-the-iis-integrated-pipeline#how-owin-middleware-executes-in-the-iis-integrated-pipeline

In the IIS integrated pipeline the request pipeline consists of HttpModules subscribed to a pre-defined set of the pipeline events such as BeginRequest, AuthenticateRequest, AuthorizeRequest, etc.

but not mention why there no httpmodule configuration in web.config

Tratcher commented 2 years ago

Since this is an old component, we don't actively update the concept docs. Feel free to use the edit option there to submit a PR.

ghost commented 2 years ago

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.