views:

43

answers:

1

I'm using MVCTurbine in my application which automatically injects my controllers in my asp.net-mvc 2.0 website. My master pages, view pages, css, web.configs and javascript files are in my mvc project, all the rest (including the global.asax) are in seperate libraries.

When I put a breakpoint at my Controller's constructors I notice that ALL the constructors are hit 4 times for each request and the controller with the actual action in gets hit an extra 5th time.

I've tried to reduce the problem surface in the following ways:

  • Reduced my view and masterpage to minimum (all custom code removed)
  • Reduced my view
  • Simplified my controller to the minimum
  • Simplified my global.asax.cs to minimum

The breakpoint has no meaningfull stacktrace.

Posted the simplified code to http://gist.github.com/514442
The problem code in context of a project can be found at http://github.com/boriscallens/Beek

I'm kind of out of ideas, any hints or ideas on how to continue debugging this are welcome.

+1  A: 

I never noticed this before :/ Anyway, after some digging, I found where it calls the constructor 4 times. It's supposed to call them 4 times only once, and cache the results (it's looking for filters), but MvcTurbine seems to be losing the instance with the cache.

This is the class that's causing problems: http://github.com/lozanotek/mvcturbine/blob/master/src/Engine/MvcTurbine.Web/Controllers/DefaultFilterFinder.cs

If you copy & paste this class into your project, and register it in one of your IServiceRegistration classes it works like it's supposed to.

locator.Register<IFilterFinder, FilterFinder>();

(I renamed the class to FilterFinder from DefaultFilterFinder)

UPDATE

I figured out why it doesn't work. It's because when I downloaded the 2.1 version from downloads, the code that caches the results is not there yet. If you download the latest source from http://github.com/lozanotek/mvcturbine, it works (you have to compile the code, not use the binaries in deploy folder).

Necros
Nice. I will check this out when I get home
borisCallens