Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of DefaultControllerFactory in Web API?

We are trying to replace previous DefaultControllerFactory with new ASP.NET Web API to better handle REST/XML calls. Searching the web always pointed to implementating System.Web.Http.Dependencies.IDependencyResolver and then handling the GetService() and few other methods required by the interface.

However it seems to be caching the ApiController instance and any new controller, it does not seem to be resolving. Its difficult to provide all possible ApiController instances during startup due to performance issues.

DefaultControllerFactory allows providing controller instances and caches the "hit" entries, but throws errors when the an instane could not be delay loaded.

Are there are other overloads/controller factory methods that requires to be implemented?

Search did not yield any hits so far, but any pointers will be great. Thank you for your time.

like image 469
sraj Avatar asked Aug 09 '12 14:08

sraj


1 Answers

It is IHttpControllerActivator implemented by DefaultHttpControllerActivator.

You may replaces it using:

GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), 
        new MyOwnActivatior());

Oops!

I meant IHttpControllerSelector!


It is IHttpControllerSelector implemented by DefaultHttpControllerSelector.

You may replaces it using:

GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerSelector), 
        new MyOwnActivatior());
like image 149
Aliostad Avatar answered Sep 18 '22 14:09

Aliostad