c# - Api Exception filters for autofac -
i have configured webapi iautofacexceptionfilter
exception details. registered things in autofac.config
httpconfiguration config = serviceconfig.initialize(new configbuilder(options, (configuration, builder) => { builder.registertype<errorloggingexceptionfilter>() .aswebapiexceptionfilterfor<basecontroller>() .instanceperapirequest(); builder.registerwebapifilterprovider(globalconfiguration.configuration); //builder.registertype<errorloggingexceptionfilter>() //.aswebapiexceptionfilterfor<basecontroller>().singleinstance(); builder.overridewebapiactionfilterfor<basecontroller>(); builder.registersource( new anyconcretetypenotalreadyregisteredsource(t => !(t.isgenerictype && t.getgenerictypedefinition() == typeof(meta<>)) )); } var serviceresolver = (autofacwebapidependencyresolver)config.dependencyresolver;
but gives me error
the
autofacwebapidependencyresolver
must configured dependency resolver web api beforeautofaccontrollerconfigurationattribute
can resolve services container controller type.
you should make autofacwebapidependencyresolver
default web api dependency resolver :
// set dependency resolver autofac. var builder = new containerbuilder(); var container = builder.build(); config.dependencyresolver = new autofacwebapidependencyresolver(container);
see autofac documentation more info.
Comments
Post a Comment