How to make a structure map powered viewengine in asp.net mvc

Posted by Andrew Bullock on Stack Overflow See other posts from Stack Overflow or by Andrew Bullock
Published on 2009-02-26T23:53:15Z Indexed on 2010/04/04 22:03 UTC
Read the original article Hit count: 394

Filed under:
|
|
|

My views extend a base view class ive made:

public class BaseView : ViewPage

At the moment im calling ObjectFactory.GetInstance inside this class' constructor to get some interface implementations but id like to use structuremap to inject them as constructor arguments.

Im using a structuremapcontrollerfactory to create my controllers, but how can i do the same for views?

I know i can implement a custom ViewEngine, but using reflector to look at the mvc default viewengine and its dependencies, it seems to go on and on and i'd rather not have to re-implement stuff thats already there. Has anyone got a cunning idea how to solve this?

I know i could make things easier with setter instead of constructor injection but id rather avoid that if possible.

© Stack Overflow or respective owner

Related posts about c#

Related posts about structuremap