Tuesday, October 13, 2009

Generate your own custom Controller and Views by overriding the default MVC T4 templates

Create a ASP.NET MVC Web Application

image

image

image

Copy the CodeTemplates directory into the root of your MVC project.

By copying this directory into your root directory you will be overriding the default templates.

The CodeTemplates directory can be found here:

C#

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC

or

VB.NET

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\VisualBasic\Web\MVC

image

Highlight each t4 template and delete the “Custom Tool” properties.

image image

Modify template(s)

image

Add new controller

image

image

Now you can see your custom created controller!!!

(This applies to the views as well)

image

0 comments:

Post a Comment