If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Injecting properties into ApiController (MVC4 WebApi) derive clasees

Hi there,

First of all I want to thank you for your great job in Spring.Net. It's really amazing! Thank you.

I hope this is the right forum where to ask. If not please accept my apologize.
As per subject, I would like to inject properties into ApiController derived classes in MVC4 Web Api, but I couldn't find how googling around.

At this time I'm inherithing from Spring.Web.Mvc3.SpringMvcApplication, but it seems it does not perform injection into ApiController derived classes.

Unfortunately I have to report that you're quite right: the Spring.Web.Mvc3.SpringMvcApplication was designed/built *before* the release of the recent WebAPI and so it most definitely doesn't support the new ApiController (or even the MVC4 Controller completely) as of yet. We are working on a release that will properly support the full compliment of DI features in both MVC4 and the HTTP WebApi release but these are not yet ready/working/releasable. Look for this in the upcoming SPRNET 2.0 release in JUN/JUL of this year but in the mean time you can also watch this JIRA issue https://jira.springsource.org/browse/SPRNET-1497 to track the progress.

Quick solution

Well' I implemented a quick solution, which you can download here (thre classes): http://www.beller-it.de/download/spring.net-webapi.zip
If your global.asax inherited from SpringMvcApplication, all you need to do is to let it inherit from WebApiSpringMvcApplication now.