0

I use a BaseController to wire up my service layer. All other controllers inherit this controller. Now I'm embarking on building an MVC2 project template. I would like controllers to inherit this by default, not just the ": Controller", but have no idea how to approach this.

2 Answers 2

3

You can use custom t4 templates to do this

http://www.davidhayden.me/2009/11/aspnet-mvc-and-t4-templates-generating-controllers-and-views.html

Sign up to request clarification or add additional context in comments.

1 Comment

Completely awesome the power of code templates. Thank you very much and I find myself wondering how much time I've lost coding over the years...
1

I'd note that if it is just to wire in a service layer, you might well be better served by using an IoC container (eg--structuremap) and dependency injection into otherwise unadulterated Controllers. Or, Composition > Inheritance any day.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.