I'm currently moving a WebApi 1 to a WebApi 2 project with OWIN.
In this piece of code GlobalConfiguration is in System.Web.Http.WebHost.
public class HandlerErrorFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
{
var logFactory = GlobalConfiguration.Configuration.DependencyResolver
.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
...
}
}
I think this is not Owin compatible, but I can't find how to rewrite this so I can access the dependency resolver.
I am not entirely clear about your question here...but GlobalConfiguration is comaptible with Owin middleware...There is also something called System.Web.Http.Owin
which is an Web API Owin Adpater middleware...if you use this adapter then GlobalConfiguration must not be used...actually this is the same adapter which is used in case of Owin Selfhost scenario too...
if you are NOT using this adapter and just using other Owin middleware along with System.Web.Http.WebHost
, then your above code should work just fine...are you seeing anything different?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With