3

What options do we have for scaffolding controllers in ASP.NET MVC (v2 and v3 RC)? I know about the code templates folder and T4 but it only allows creating one .tt file and thus, replacing the default controller template with your own but what I would need is different types of templates for various types of controllers.

I've heard that Rails has huge support for this. I'm also aware of the MvcScaffold package in MVC 3 (via NuGet) as described and developed by Scott Hanselman which supports ControllerWithContext and ControllerWithRepository but I would like to take this further and since the source code hasn't been published (at least I'm not aware of it) there isn't much I can do to customize it.

What do you guys use or do?

2
  • What use-case dictates code-generation of the controllers rather than simple object inheritance? Commented Dec 2, 2010 at 17:15
  • Well as I said I am open to suggestions and inheritance is one of them and I actually use it already. But inheritance still requires us to override base class methods so code still needs to be written (rather then generated by some scaffolding method). Commented Dec 2, 2010 at 17:38

1 Answer 1

3

There is the Generic Controller (Controller<T>) technique. Big fan.

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

1 Comment

Looks are deceiving. Getting a good generic scaffold controller going requires a lot of work. ;)

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.