views:

16

answers:

2

I would like to edit the ASP.NET MVC templates for Visual Studio so that any new action or controller created has a specific piece of code within it by default.

For instance, I'd like to replace the generated:

    public ActionResult MyAction()
    {
        return View();
    }

with a specific coding standard we prefer to use within in my team. eg:

    public ActionResult About()
    { 
        try 
        {
             DoStuff();
             return View();
        }
        catch(Exception)
        {
             HandleException();
        }
    }

I've looked through the filesystem, but I cannot find anything specific that relates to the ASP.NET mvc templates. Anyone know where they are?

A: 

You may take a look at the following location:

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

Link for ASP.NET MVC 2 Project templates, not sure if same for ASP.NET MVC 1.0 though.

Darin Dimitrov
A: 

All inbuilt project templates are held in %VS-Root%\Common7\IDE\ProjectTemplates.

MVC project templates here (with my non-standard install folder) are C:\VS2008\Common7\IDE\ProjectTemplates\CSharp\Web\1033\MvcWebApplicationProjectTemplatev1.cs.zip and C:\VS2008\Common7\IDE\ProjectTemplates\VisualBasic\Web\1033\MvcWebApplicationProjectTemplatev1.vb.zip.

Richard
Ah, yes, thank you. Completely forgot that I had installed VS on another partition and was going mad trying look for these directories that didnt exist. Thanks!
Jason