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
{
开发者_如何学Go 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?
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
.
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.
精彩评论