Closed ghost closed 7 years ago
You shouldn't need to register the handler in web.config at all. It registers itself via pre app start: https://github.com/aspnet/AspNetKatana/blob/3580ddd66ca91b495d1c1f23f193d7cf5a9a3f42/src/Microsoft.Owin.Host.SystemWeb/PreApplicationStart.cs#L11
The thing is, when I remove that handler all our images are not served anymore. We have it registered like this:
app.UseFileServer(new FileServerOptions {
FileSystem = new PhysicalFileSystem(@"C:\images"),
RequestPath = new Microsoft.Owin.PathString("/images")
});
https://github.com/aspnet/AspNetKatana/wiki/Static-Files-on-IIS Try enabling runAllManagedModulesForAllRequests
Looks like we did something wrong wit the stage markers. In one place it still not worked with the "runAllManagedModulesForAllRequests".
Thanks for your help!
Another option is appsetting <add key="owin:AutomaticAppStartup" value="false" />
in web.config. That makes sure the module isn't added in pre app start
https://github.com/aspnet/AspNetKatana/blob/3580ddd66ca91b495d1c1f23f193d7cf5a9a3f42/src/Microsoft.Owin.Host.SystemWeb/PreApplicationStart.cs#L32
Late answer and somehow already answered above, but just to add some clear answer in case could help to anyone landing in this post.
I had exactly the same problem as the OP (Owin startup called twice) and also the issue when removing the Owin handler from web.config (no static files served). Finally the problem was an incorrect setup of the Owin static file server.
I removed Owin handler from web.config and setup the Owin static file server with the proper stage marker: app.UseStageMarker(PipelineStage.MapHandler);
Refer to this (As previously mentioned): https://github.com/aspnet/AspNetKatana/wiki/Static-Files-on-IIS
@Tratcher what did you mean by static file middleware
? how can I invoke it?
Also, add the following stage marker AFTER your static file middleware (in namespace Microsoft.Owin.Extensions):
Comments on closed issues are not tracked, please open a new issue with the details for your scenario.
Hi,
My Configuration method in the Startup class is invoked twice.
I debugged Microsoft.Owin.Host.System.Web and found out the first time it's invoked from OwinHttpModule.Init and the second time it's invoked by OwinApplication through OwinHttpHandler.BeginProcessRequest
In my web.config I have the following handler registered so everything is routed through owin
Here the stack trace for the first execution
And the stack trace for the second execution
Any idea what I'm doing wrong?