61

I'm using Visual Studio 2012 and have just installed "Microsoft ASP.NET and Web Frameworks 2013.1 - Visual Studio".

As expected, it added the option to create an "ASP.NET MVC 5 Empty Project". The thing is, I see no way of jump-starting an already functional "base application" as I had when I was using MVC 4 (e.g. "Asp.NET MVC 4 Web Application"). I only see an empty template.

I've seen answers such as:

And found this article on the matter.

This is obviously not a show-stopper as I can always create the application from a scratch, but I still would like to know if it is possible to achieve that on VS 2012. Did I miss a step, or do I need VS 2013 for that? A fully functional Web application template (with authentication etc.) would be nice to dabble around MVC 5's new features or for prototyping.

Community
  • 1
  • 1
user1987392
  • 3,921
  • 4
  • 34
  • 59
  • This is an important topic as many azure tutorials depend on the files setup in that web application to connect to SQL Server. I need to figure this out as well. – Eric Bishard Dec 23 '13 at 09:33
  • 3
    MVC 5 is meant to work with VS 2013 out of the box. Not so with VS 12. With the free VS Express 2013 web, there is no reason not to use 2013 for this. – Greg Gum Jan 01 '14 at 19:17
  • 5
    @GregHollywood: How can that be no reason to use 2012 or 2012 paid versions of vs? UnitTests? Static code analysis? All of the nice goodies you get with the version you paid much won't be there in Express – Tseng Feb 20 '14 at 00:22
  • @Tseng, agreed. And I also have some paid dev. tools on 2012. I ended up using VS Express 2013 to generate the project (template/"skeleton") and then I worked on it using VS2012. User Sean Lynch provided a good answer in the meantime. – user1987392 Feb 20 '14 at 08:29
  • @Tseng, agreed. I much prefer the paid version, which I have and use (both 2012 and 2013). My point to the OP was that if he just wanted to play around with MVC 5, he could do so in the Express version for free. – Greg Gum Feb 20 '14 at 15:14

4 Answers4

78

After creating a new project using ASP.NET MVC 5 Empty Project, you can right click on the project, then click Add.. > New Scaffolded Item..., select MVC on the left, then MVC 5 Dependencies and choose Full dependencies from the prompt.

This will add a default layout (Views\Shared\_Layout.cshtml), Content folder, Scripts folder with bootstrap, jquery, modernizr, etc, and other things the Web Application template creates.

If you get the error "CS0103: The name 'Styles' does not exist in the current context" just add <add namespace="System.Web.Optimization"/> under <namespaces> in Views/web.config

nikib3ro
  • 20,366
  • 24
  • 120
  • 181
Sean Lynch
  • 6,267
  • 2
  • 43
  • 45
  • 2
    This worked great for me! Only small thing is that it didn't add the default Home controller and associated View, but that's no biggie. Thanks so much! – John Washam Feb 19 '14 at 17:03
  • 7
    And, if you get the error "CS0103: The name 'Styles' does not exist in the current context" just add `` under `` in `Views/web.config`. – user1477388 Apr 07 '14 at 12:47
  • 1
    Rosdi Kasim's answer helped me get what I actually wanted :P – John Oct 23 '14 at 18:48
  • This feature is now available for VS.2012 at `Web Platform Installer`. Just search for `ASP.NET and Web Tools 2012.2` and add to install: http://i.stack.imgur.com/pRTSe.jpg – Rodrigo Reis Jan 20 '16 at 16:03
34

The answer from Sean Lynch is nice but not really complete.

However there is this nice guy that took the time to prepare the template just like in Visual Studio 2013. You will get everything down to the bootstrap template and pre-configured database table for authentication.

All you need to do is change the DefaultConnection in Web.Config to you SQL Server and voila all the relevant authentication table will be created for you.

Archive of the original blog (by web.archive.org)

Update

The original blog is no longer online, but thankfully his template is still online. You can download the MVC5 Template for Visual Studio 2012 Here:

Direct link to MVC5 Template For Visual Studio 2012

And here is the excerpt from the original blog:


Installing the template is very simple, there are just two steps:

Copy it into the following folder of your computer (creating the directory structure if necessary):

%USERPROFILE%\Documents\Visual Studio 2012\Templates\ProjectTemplates\Visual C#\Web

Once you’ve done this, simply restart Visual Studio and you will have this template available in the dialog box to create a new project under “Visual C# > Web”.

Now you can create applications with a little more shape than the mere empty structure provided by default and enjoy the benefits of adopting Bootstrap and its responsive design, a full membership system and user authentication, bundles, filters, some content pages, etc.


forsvarir
  • 10,749
  • 6
  • 46
  • 77
Rosdi Kasim
  • 24,267
  • 23
  • 130
  • 154
  • 2
    I think this should be the right answer. working great for me! – Rahul Patel Aug 02 '14 at 12:29
  • Thanks, just want to mention if like me you we unsure of how to add the template , just copy it under my documents , in the VS templates folder. – John Oct 23 '14 at 18:49
  • works great, if you get a system.web.mvc does not exist error just clean the solution and set the copy local property to true on that reference – Eamon Nov 06 '14 at 15:15
  • 1
    @Eamon `system.web.mvc` has recently been updated. The correct fix is to update the `system.web.mvc` reference via nuget. – Rosdi Kasim Nov 07 '14 at 01:36
  • 1
    nice one, that simply works! Only thing I'd mention is that if you are a dummy, like me, then don't be tempted to copy the contents of the zip file to the folder mentioned, you need to just copy the zip file itself. I know that's what the instructions say but I thought it worth repeating. – naskew Dec 23 '14 at 11:05
  • This link redirects to a non-English page. – laylarenee Mar 04 '15 at 14:02
  • @laylarenee Yep the link does not work anymore. But any reason why you still looking for this? Visual Studio 2013 is now available for free (for small companies anyway). I don't see any reason why you would need this template anymore. – Rosdi Kasim Mar 04 '15 at 15:36
  • 3
    @laylarenee I found the direct link to the template. I have updated my answer to put the new link. – Rosdi Kasim Mar 05 '15 at 15:46
  • Thanks for the updated link. I am not eligible to use the Community Visual Studio for work purposes due to income restrictions. – laylarenee Mar 05 '15 at 16:43
  • Thanks Rosdi, i think that should be the right answer great job. – Bahaa Hany Aug 22 '15 at 21:55
  • In case you aren't seeing the template after installation: (1) check where Visual Studio is looking for templates under Tools -> Options -> Projects and Solutions -> User project templates location (2) make sure you COPY the .zip file to the location, do **not** decompress it. – Ian Kemp Sep 24 '15 at 10:35
1

You have 2 option to fix it.

  1. Install the latest 2013 version which have MVC5 support inbuilt (VS2013 missing MVC3 and ASPX file template (ASPX templates will be added in future))

  2. stay with 2012 update 4. Read my old article to get it fixed http://geekswithblogs.net/anirugu/archive/2013/11/28/mvc-5-in-visual-studio-2012-update-4.-how-to.aspx

Anirudha Gupta
  • 9,073
  • 9
  • 54
  • 79
  • Option 2 worked for me. For a shorter path to the install and microsoft documentation. Go here: http://blogs.msdn.com/b/webdev/archive/2013/11/18/announcing-release-of-asp-net-and-web-tools-2013-1-for-visual-studio-2012.aspx – Richard Collette Oct 31 '14 at 12:46
0

I'm not using 2012 now, but rather 2013, and I see the mvc 5 template there. However, I did this a while back before I had any mvc 5 templates showing up by installing mvc 5 first. You should be able to download from http://www.asp.net/mvc/mvc5. Also make sure your target framework is set correctly. Then I updated the web config like this: You have to have the correct versions of the assemblies. I googled a lot to get this info, so it should still be available if you do some research.

  • Note: The web config needs to have the assembly identities for the items such as web.helpers, webpage, mvc, razor, etc., set the correct version compatible with mvc 5. For example, – Paul Ayraud Mar 06 '15 at 00:15
  • Please edit your question rather than posting information in comments. – Jeffrey Bosboom Mar 06 '15 at 00:25