No ASP.NET MVC 5 Web Application Template on VS 2012? - asp.net-mvc

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:
How can I add the MVC 5 project template to VS 2012?
Create and Run MVC 5 Project in VS 2012
Direct download link to ASP.NET MVC 5 for VS 2012
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.

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

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.

You have 2 option to fix it.
Install the latest 2013 version which have MVC5 support inbuilt (VS2013 missing MVC3 and ASPX file template (ASPX templates will be added in future))
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

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.

Related

Updated ASP.NET Web Application (.NET Framework) MVC5 Project Template

The project that visual studio 2019 creates for an ASP.NET Web Application (.NET Framework) MVC5 comes with Bootstrap 3.x and many other outdated components. Not to mention unneeded things like modernizr.
If you update Bootstrap, you know need to modify the ScriptBundle in BundleConfig to get the application to start, and then modify the CSS to get the premade web pages to render properly.
Also, the folder structure is not the best.
Is there a project template out there that has all essential components updated, and a clean-up NuGet and folder structure?
I tried using Rider but they do not have a built-in template.
I went t the .Net Foundation GitHub and did not find any: https://github.com/dotnet?q=.NET+framework&type=&language=c%23&sort=
I also search GitHubub and did not see any: https://github.com/search?q=ASP.NET+Web+Application+%28.NET+Framework%29+project+template
I am looking for a project template that has the basic structure to create a Clean Architecture in .NET Framework and not .NET Core
I know it's legacy, but unfortunately, I need it for a university class (University courses take a while to get updated, and in this case, they claim that there are sufficient companies out there using ASP.NET MVC 5 to Merrit them teaching it) But yes, No one should be using this to start a new project they intend to put into a real-life production scenario.
Thank you

Visual Studio Update 2015, many options for ASP.NET MVC project missing

I just installed Visual Studio 2015 Update 1, and a lot of the configuration I was used to is missing or different. I'd like to know if these changes are due to something simple (like a package I need to install), or if it's something a little more complex.
I'm mainly using Visual Studio to create MVC apps from scratch, so before the update, I would create an empty MVC app with the "Add core references and folders for MVC" selected. Now, I can only create an empty MVC project with nothing pre-configured, or a fully scaffolded MVC app.
In the empty MVC project, there's no option to "Add Controller" when I right-click the "Controllers" folder I create. However, this option is available in the generated one.
The Add New Item menu is divided into Server-side and Client-side templates for the generated app, but it's divided into Code/Data/General/Web/etc. in the empty app. There's also an option to add an MVC View in the generated app, but there's nothing with Razor for the empty app. No .cshtml intellisense in the empty app, either.
There's a lot of functionality and options missing from the empty app that seem like they have to do with how the app is an MVC app, since they're available for the generated app. Is there a straightforward fix that will allow me to create an MVC app using Razor from an empty template?
Figured it out! I was using the ASP.NET 4.5.2 Empty Template, and choosing the ASP.NET 5 Template solved the problem.

how to add asp.net mvc templates for monodevelop

I'm on archlinux using mono 4.0.4 and monodevelop 5.9.
By following the Getting started guide I noticed there are some scaffolding options missing, I see some nuget packages for scaffolding but installing them didn't do much.
SO has these two questions :
How to get the MVC 3 or 4 template in MonoDevelop?
Developing ASP.NET MVC using MonoDevelop on MAC
The latter is for Mac and both of them are outdated As I'm talking about asp.net mvc 5 here.
searching didn't reveal anything apart from the Nuget packages I added and I can't see any addins in the add-in manager for this(prefer not to use beta or alpha addins).
So what to do to get these ?
P.S:
I know I can get them with yoeman but I like to use monodevelop, if yoeman can be integrated with monodevelop So I can see options like "model with view and controller" scaffolding(that is a CRUD ready application) then I'll do it.
I am assuming you are talking about the templates that are available in an ASP.NET MVC application when you select Add View or Add Controller. If this is not the case then please update your question with more information.
The templates listed when adding a new view or controller to an ASP.NET MVC project are taken from t4 template files (.tt) in the following folders:
AddIns\AspNet\CodeTemplates\CSharp\AddController
AddIns\AspNet\CodeTemplates\CSharp\AddView\Razor
You can add extra .tt files into this folder and they will be displayed in the Add View and Add Controller dialog.
Out of the box MonoDevelop/Xamarin Studio only has a few t4 templates available so you would need to either write your own or find some from elsewhere. SharpDevelop has more T4 templates or MVC which could probably be used but may require some modification.

Create and Run MVC 5 Project in VS 2012

For some reason my Visual Studio 2013 Preview cannot create MVC 5 Projects. Since the MVC project is now open source in CodePlex I was wondering if there's a simple way to develop MVC 5 projects in my Visual Studio 2012 Ultimate.
Microsoft has released updated Web Tools 2013.1 that provide the support:
Description
Direct download
Note that I had to install it manually from the second link, the tools did not install properly from Web Platform Installer. Also a colleague had to install both Update 4 and these tools to get proper support.
Original answer (not actual anymore):
I received this answer from Microsoft developer:
MVC 5/Razor 3 tooling support for VS 2012 has not shipped yet. We hope to ship this support in Mid November.
Recently ASP.NET Program Manager from Microsoft mentioned in a talk that this would be included in VS2012 Update 4. Edit: unfortunately the support is not in Update 4.
So the accepted answer is true for now but we can plan to soon have this support in VS2012 as well.
A new tutorial has been recently added to the ASP.NET website on how to upgrade an MVC4 project to MVC5.
I migrated a VS 2012 project using this tutorial without problems, but there is no design time support for Razor 3 in VS2012 due to changes in the way VS loads the razor engine.
You can edit razor pages in VS2012, but it will be a plain HTML editor.
Microsoft has released an update for this, Web Tools 2013.1 for VS2012.
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
I'm not sure MS will fix it.
The bug report says problem closed : by design
https://connect.microsoft.com/VisualStudio/feedback/details/806348/razor-intellisense-does-not-work-in-visual-studio-2012-after-upgrading-to-mvc-5-razor-3
and it is mid November
I have a tutorial that will not only get your empty MVC 5 project working with Bundling, a controller, jQuery, jQuery UI, Modernizr and more, but it will walk you through installing Zurb's Foundation 5, a responsive Framework which I have working with Sass in MVC 5. It's all here:
http://tinyurl.com/VS12-MVC5-F5
The problem many have ran into is that Visual Studio 2012 only allows you to start from a blank MVC 5 project, so I will help you get the NuGet installed which is pretty similar to the instructions in the NuGet package with a few minor changes; however, it does not take into consideration that you will be installing from Visual Studio 2012 using a Blank MVC 5 project. If you would like to use Foundation 5 with MVC 4 Web Application template just omit the Bootstrap uninstall and the NuGet package should work fine, but if you need to use MVC 5 and you don’t have Visual Studio 2013, you will need to build the Home Controller, Bundling class, modify the Global.asax.cs as well as other quirky little things. So lets get started.
I spent a good part of a few hours getting it all working.

Convert Visual Studio project to ASP.NET MVC

I have a visual studio project which is an ASP.NET MVC project, however it doesn't recognize it as such in Visual Studio so I don't get the nice dropdowns with Add View and such. Rather I just get a very plain add file dialog which doesn't include any MVC file templates. When I create a new MVC project however I get all the nice little VS tools. So, can someone tell me how I can instruct VS to recognize the project as an MVC project?
Thanks
For ASP.Net MVC 3, you will have to change the ProjectTypeGuids property in the project file to:
<ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Well, to answer my own question, you have to change the projecttypeguids in the project file. In the case of ASP.NET MVC RC1 they are:
{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
Though of course these may vary depending on the version you're targeting.

Resources