Search
Categories
Navigation
Twitter Updates

Twitter Updates

    follow me on Twitter
    « Getting Outside the Microsoft Echo Chamber | Main | Code Fossil: CacheManager »
    Friday
    Oct092009

    Empty ASP.NET MVC 1.0 Project Template

    Empty stadium seats - Photo by: laffy4k (Flickr)The project template that ships with ASP.NET MVC 1.0 is nice when you first start using the framework and want to see how things work together. Unfortunately, it can be annoying once you actually start using the framework for real projects. This is because the first thing you typically need to do is delete all the extra stuff the template creates, but you don’t want in your project.

    After having done this more than a few times, I decided to create my own empty ASP.NET MVC project template with all the stuff I rip out and change already done. This empty MVC template has a few substantive changes:

    • There are no default controllers or views, just folders for their locations.
    • There are no included JavaScript libraries, jQuery or otherwise.
    • All the Web.config settings dealing with ASP.NET Ajax have been removed
    • All the Web.config settings dealing with the profile, role and membership services have been removed
    • The folder structure for images, Javascript and CSS has been changed to Assets/img/, Assets/js/, and Assets/style/, respectively.

    The guiding principle here is that every project tends to be a bit different, so starting from scratch is often easiest. The stock Web.config files have a lot of extra stuff in them that may not be all that relevant for a lot of projects, and I’d rather add stuff back in than have a bunch of unused boilerplate all the time. Plus, I just don’t see much purpose for ASP.NET Ajax at this point in time.

    The image, script and style folder change is just personal preference; I don’t like having Content and Scripts folders like the standard MVC project template does.

    A quick note about testing projects: This template won’t prompt you to create a testing project like the standard MVC template does. This is not because I think unit testing is dumb (quite the contrary) but because I tend to use my own project structure for testing projects as well, so I don’t have a need for it.

    Installation

    I’ve posted my Empty ASP.NET MVC 1.0 project template, if you’re interested in using it.

    If you’ve never installed a custom template before, it’s as easy as copying the zip file to \My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual C#\. Alternatively, if you want the project to show up under the Web sub-category you can place the zip file in \My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual C#\Web\.

    After copying the file to the correct location, you should see the new project template when you go to create projects within VS:

    proj-template

    Creation

    If you’d like to have a similar project template, but don’t like some of the changes I’ve made, it’s fairly simple to create your own Visual Studio project templates. In fact, all the documentation I used is available on MSDN:

    Additionally, if you’d like to look at the standard ASP.NET MVC project template (MvcWebApplicationProjectTemplatev1.cs.zip) you can find it installed to <VisualStudioInstallDirectory>\Common7\IDE\ProjectTemplates\CSharp\Web\<Locale>\.

    I’m sure I’ll keep tweaking things about my empty MVC project template (I’m already considering deleting the Models directory since I tend to use a separate assembly for them) but I’m happy with it as a first iteration. It’s a pretty simple process to create one, so if you’ve been annoyed at the stock MVC template, it’s worth the minimal time investment.

    This post targets Visual Studio 2008 and ASP.NET MVC 1.0 using C#. The content may not be relevant for other product, framework or language versions.

    PrintView Printer Friendly Version

    EmailEmail Article to Friend

    Reader Comments

    There are no comments for this journal entry. To create a new comment, use the form below.

    PostPost a New Comment

    Enter your information below to add a new comment.

    My response is on my own website »
    Author Email (optional):
    Author URL (optional):
    Post:
     
    Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>