0

I've been playing with Spring.NET 2.0.0M1's support for ASP.NET MVC4. While promising, I think I've run into a critical issue: a new MvcApplicationContext is created for each hit (when using MVC4's WebApi). While I believe the purpose of this is to support the additional scopes, the debugging I've done so far suggests that the new MvcApplicationContext is created with the overall application's WebApplicationContext as the parent ApplicationContext and is given the same config locations as the parent. As such, this new child MvcApplicationContext loads the same config locations and recreates all of objects, including all of your singletons, and never delegates to the parent context. This effectively makes singletons unusable, and effectively binds everything to the request scope (or lower).

The relevant code which is creating the new MvcApplicationContext is lines 43 to 52 of Spring.Web.Mvc4/SpringWebApiDependencyResolver.cs in master right now.

I don't have enough experience in Spring.NET to know what the correct fix/workaround is, but I'm willing to experiment if anyone has ideas. If there's agreement that this is a bug, I'd be happy to open-up an issue.

I might be making a mistake on my end, but I have compared this to the samples and haven't found an obvious problems.

TTar
  • 905
  • 1
  • 8
  • 12
  • Good point, but I think this is more appropriate for the spring framework forum - ah, [I see you've posted there already](http://forum.springframework.net/showthread.php?10222-New-MvcApplicationContext-is-created-for-each-hit-when-using-MVC-4-in-2-0-0-M1) – Marijn Jun 29 '12 at 07:45
  • Replied to this in the post in the Spring.NET forums (its the result of a partially-implemented feature in the M1 release). – sbohlen Jul 04 '12 at 13:06
  • [spring.net issue 1512](https://jira.springsource.org/browse/SPRNET-1512) – Marijn Jul 10 '12 at 06:57

0 Answers0