MVC Version(s) With VS 2015

If your mind got stuck in the installation of different versions of MVC with respect to  the newer version of Visual Studio, then this article will give you a brilliant approach to get rid of this mess.

Unfortunately, Microsoft doesn’t give us common UI to add different versions of MVC in our project.

So in this blog, I will explain a common approach to add different MVC version(s).

Teaser

Here, we are going to use MVC(n) NuGet Package.

Steps to work with different versions of MVC with Visual Studio 2015 or greater 

Create new project (Here, I am using VS2015).

 
Choose ASP.NET Web Application from project window.

Can uncheck “Add Application insight..” option. It doesn’t have any role in our process.

Select “Empty” template from project window.

NOTE 

Select MVC option from
Add folders and core..”.

Now, we are ready with our project to install all the MVC versions one by one.

Open “Package Manager Console” for MVC installation.

MVC 2 installation in Visual Studio 2015
 
 PM> Install-Package MVC2
 


MVC 3-4-5 installation in Visual Studio 2015

PM> Install-Package Microsoft.AspNet.Mvc -Version <Your desired MVC version goes here>

NOTE

  1. You can choose your desired MVC version from here.
  2. For installed MVC version verification, Find “System.Web.MVC” library under “Refrence” folder and right click on it and select "Properties".
  3. Under “Version” field, we get “3.0.0”, hence we installed MVC3.
  4. Programitacally, we can use "typeof(Controller).Assembly.GetName().Verasion.ToString()" to get the installed MVC version.
  5. If you have created the MVC project in greater MVC version and trying to install minor MVC version one. Might you will get some errors for advanced features that has been added at the time of project creation. So in that case remove those from your project.