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 before autofaccontrollerconfigurationattribute 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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -