Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Setting Up the Environment for ASP.NET MVC 6

Save for later
  • 9 min read
  • 02 Nov 2016

article-image

In this article by Mugilan TS Raghupathi author of the book Learning ASP.NET Core MVC Programming explains the setup for getting started with programming in ASP.NET MVC 6. In any development project, it is vital to set up the right kind of development environment so that you can concentrate on the developing the solution rather than solving the environment issues or configuration problems. With respect to .NET, Visual Studio is the de-facto standard IDE (Integrated Development Environment) for building web applications in .NET.

In this article, you'll be learning about the following topics:

  • Purpose of IDE
  • Different offerings of Visual Studio
  • Installation of Visual Studio Community 2015
  • Creating your first ASP.NET MVC 5 project and project structure

(For more resources related to this topic, see here.)

Purpose of IDE

First of all, let us see why we need an IDE, when you can type the code in Notepad, compile, and execute it.

When you develop a web application, you might need the following things for you to be productive:

  • Code editor: This is the text editor where you type your code. Your code-editor should be able to recognize different constructs such as the if condition, for loop of your programming language. In Visual Studio, all of your keywords would be highlighted in blue color.
  • Intellisense: Intellisense is a context aware code-completion feature available in most of the modern IDEs including Visual Studio. One such example is, when you type a dot after an object, this Intellisense feature lists out all the methods available on the object. This helps the developers to write code faster and easier.
  • Build/Publish: It would be helpful if you could build or publish the application using a single click or single command. Visual Studio provides several options out of the box to build a separate project or to build the complete solution at a single click. This makes the build and deployment of your application easier.
  • Templates: Depending on the type of the application, you might have to create different folders and files along with the boilerplate code. So, it'll be very helpful if your IDE supports the creation of different kinds of templates. Visual Studio generates different kinds of templates with the code for ASP.Net Web Forms, MVC, and Web API to get you up and running.
  • Ease of addition of items: Your IDE should allow you to add different kinds of items with ease. For example, you should be able to add an XML file without any issues. And if there is any problem with the structure of your XML file, it should be able to highlight the issue along with the information and help you to fix the issues.

Visual Studio offerings

There are different versions of Visual Studio 2015 available to satisfy the various needs of the developers/organizations. Primarily, there are four versions of Visual Studio 2015:

  • Visual Studio Community
  • Visual Studio Professional
  • Visual Studio Enterprise
  • Visual Studio Test Professional

System requirements

Visual Studio can be installed on computers installed with Operation System Windows 7 Service Pack1 and above. You can get to know the complete list of requirements from the following URL:

https://www.visualstudio.com/en-us/downloads/visual-studio-2015-system-requirements-vs.aspx

Visual Studio Community 2015

This is a fully featured IDE available for building desktops, web applications, and cloud services. It is available free of cost for individual users.

You can download Visual Studio Community from the following URL:

https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx

Throughout this book, we will be using the Visual Studio Community version for development as it is available free of cost to individual developers.

Visual Studio Professional

As the name implies, Visual Studio Professional is targeted at professional developers which contains features such as Code Lens for improving your team's productivity. It also has features for greater collaboration within the team.

Visual Studio Enterprise

Visual Studio Enterprise is a full blown version of Visual Studio with a complete set of features for collaboration, including a team foundation server, modeling, and testing.

Visual Studio Test Professional

Visual Studio Test Professional is primarily aimed for the testing team or the people who are involved in the testing which might include developers. In any software development methodology—either the waterfall model or agile—developers need to execute the development suite test cases for the code they are developing.

Installation of Visual Studio Community

Follow the given steps to install Visual Studio Community 2015:

  1. Visit the following link to download Visual Studio Community 2015:

    https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx

    setting-environment-aspnet-mvc-6-img-0

  2. Click on the Download Community 2015 button. Save the file in a folder where you can retrieve it easily later:

    setting-environment-aspnet-mvc-6-img-1

  3. Run the downloaded executable file:

    setting-environment-aspnet-mvc-6-img-2

  4. Click on Run and the following screen will appear:

    setting-environment-aspnet-mvc-6-img-3

There are two types of installation—default and custom installation. Default installation installs the most commonly used features and this will cover most of the use cases of the developer. Custom installation helps you to customize the components that you want to get installed, such as the following:

  1. Click on the Install button after selecting the installation type.
  2. Depending on your memory and processor speed, it will take 1 to 2 hours to install.

    setting-environment-aspnet-mvc-6-img-4

  3. Once all the components are installed, you will see the following Setup completed screen:

    setting-environment-aspnet-mvc-6-img-5

Installation of ASP.NET 5

When we install the Visual Studio Community 2015 edition, ASP.NET 5 will not have been installed by default. As the ASP.NET MVC 6 application runs on top of ASP.NET 5, we need to install ASP.NET 5.

There are couple of ways to install ASP.NET 5:

  • Get ASP.NET 5 from https://get.asp.net/

    setting-environment-aspnet-mvc-6-img-6

    Unlock access to the largest independent learning library in Tech for FREE!
    Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
    Renews at $19.99/month. Cancel anytime
  • Another option is to install from the New Project template in Visual Studio

This option is bit easier as you don't need to search and install.

The following are the detailed steps:

  1. Create a new project by selecting File | New Project or using the shortcut Ctrl + Shift + N:

    setting-environment-aspnet-mvc-6-img-7

  2. Select ASP.NET Web Application and enter the project name and click on OK:

    setting-environment-aspnet-mvc-6-img-8

  3. The following window will appear to select the template. Select the Get ASP.NET 5 RC option as shown in the following screenshot:

    setting-environment-aspnet-mvc-6-img-9

  4. When you click on OK in the preceding screen, the following window will appear:

    setting-environment-aspnet-mvc-6-img-10

  5. When you click on the Run or Save button in the preceding dialog, you will get the following screen asking for ASP.NET 5 Setup. Select the checkbox, I agree to the license terms and conditions and click on the Install button:

    setting-environment-aspnet-mvc-6-img-11

  6. Installation of ASP.NET 5 might take couple of hours and once it is completed you'll get the following screen:

    setting-environment-aspnet-mvc-6-img-12

During the process of installation of ASP.NET 5 RC1 Update 1, it might ask you to close the Visual Studio. If asked, please do so.

Project structure in ASP.Net 5 application

Once the ASP.NET 5 RC1 is successfully installed, open the Visual Studio and create a new project and select the ASP.NET 5 Web Application as shown in the following screenshot:

setting-environment-aspnet-mvc-6-img-13

A new project will be created and the structure will be like the following:

setting-environment-aspnet-mvc-6-img-14

File-based project

Whenever you add a file or folder in your file system (inside of our ASP.NET 5 project folder), the changes will be automatically reflected in your project structure.

Support for full .NET and .NET core

You could see a couple of references in the preceding project: DNX 4.5.1 and DNX Core 5.0. DNX 4.5.1 provides functionalities of full-blown .NET whereas DNX Core 5.0 supports only the core functionalities—which would be used if you are deploying the application across cross-platforms such as Apple OS X, Linux. The development and deployment of an ASP.NET MVC 6 application on a Linux machine will be explained in the book.

The Project.json package

Usually in an ASP.NET web application, we would be having the assemblies as references and the list of references in a C# project file. But in an ASP.NET 5 application, we have a JSON file by the name of Project.json, which will contain all the necessary configuration with all its .NET dependencies in the form of NuGet packages. This makes dependency management easier. NuGet is a package manager provided by Microsoft, which makes the package installation and uninstallation easier. Prior to NuGet, all the dependencies had to be installed manually. The dependencies section identifies the list of dependent packages available for the application. The frameworks section informs about the frameworks being supported for the application. The scripts section identifies the script to be executed during the build process of the application. Include and exclude properties can be used in any section to include or exclude any item.

Controllers

This folder contains all of your controller files. Controllers are responsible for handling the requests and communicating the models and generating the views for the same.

Models

All of your classes representing the domain data will be present in this folder.

Views

Views are files which contain your frontend components and are presented to the end users of the application. This folder contains all of your Razor View files.

Migrations

Any database-related migrations will be available in this folder. Database migrations are the C# files which contain the history of any database changes done through an Entity Framework (an ORM framework). This will be explained in detail in the book.

The wwwroot folder

This folder acts as a root folder and it is the ideal container to place all of your static files such as CSS and JavaScript files. All the files which are placed in wwwroot folder can be directly accessed from the path without going through the controller.

Other files

The appsettings.json file is the config file where you can configure application level settings. Bower, npm (Node Package Manager), and gulpfile.js are client-side technologies which are supported by ASP.NET 5 applications.

Summary

In this article, you have learnt about the offerings in Visual Studio. Step-by-step instructions are provided for the installation of the Visual Studio Community version—which is freely available for individual developers. We have also discussed the new project structure of the ASP.Net 5 application and the changes when compared to the previous versions.

In this book, we are going to discuss the controllers and their roles and functionalities. We'll also build a controller and associated action methods and see how it works.

Resources for Article:


Further resources on this subject: