Tuesday, 30 August 2016

CRUD operations in ASP.NET Core 1.0 MVC Application Part 2

Let's first add View Model in application flow, then we will discuss data annotation and Tag Helpers. We have created a Get Details functionality in our previous discussion CRUD operations in ASP.NET Core 1.0 MVC Application Part 1. As we can see that we have hard coded Headings and embedded code to generate required HTML. Although this approach works fine for simple views, but we have to take care of lot of things and to write lot of code to handle features like forms and validations.
Similarly, it is not a good practice to use Models associated with Data Source like Entity Framework or Data Contracts from Services in Views. Instead of them, very concise and simple models are passed to views which called as ViewModels. These ViewModels are based on concept of POCO (Plain Old CLR Object). We will discuss pros and cons of POCO or ViewModels in detain in different session.

Add Contact View Model in Project

  • Open existing Solution in Visual Studio 2015.
  • Add new Folder Models in root of WebApplicationCore.NetCore Project
  • Now Create a Sub folder Contact in Models Folder
  • Now Add a new class ContactVM.CS in Models >> Contact.
  • Add required properties in ContactVM.
 public class ContactVM  
   {  
     public Contact()  
     {  
     }  
     public int ContactId { get; set; }  
     public string Name { get; set; }  
     public string Address1 { get; set; }  
     public string Address2 { get; set; }  
     public string City { get; set; }  
     public string ProvinceState { get; set; }  
     public string ZipPostalCode { get; set; }  
     public string Country { get; set; }  
     public string ContactNumber { get; set; }  
     public string Email { get; set; }  
     public string WebSite { get; set; }  
   }

Update Contact GetContact View

  • Change _ViewImports.cshtml by including name space of WebApplicationCore.NetCore.Models. So we can access Contact View Model without fully qualified name.
  • Use as model ContactVM in View instead of Contact.
  • Update GetContact view use LabelTagHelper to display field headings from View Model instead of hard codded text.
    • Here we have used LabelTagHelper which uses the text from provided data filed. If provided has Display Attribute then it will use text from this attribute. Alternatively, it will displays the field name. We just have to provide asp-for tag (or other asp- depending on Tag Helper) with field name from model. 
    • On the other, hand we have to just display the text, so there is ideally no need to use any data notation for a simple view. 
    • Tag Helpers are special feature to enable server side code to create, update and render HTML in view file. They are said to be evaluation of Html Helpers. Although, Html Helpers do exist, yet Tag Helpers are very popular as they are just additional attributes   in existing Html elements and are very easy for UI designers or front stack developers to understand. We will discuss Tag Helpers in detail in future sessions.  
 @model ContactVM  
 <h2>Contact</h2>  
 <div>  
   <dl class="dl-horizontal">  
     <dt>  
       <label asp-for="Name"></label>  
     </dt>  
     <dd>  
       <span>@Model.Name</span>  
     </dd>  
     <dt>  
       <label asp-for="Address1"></label>  
     </dt>  
     <dd>  
       <span>@Model.Address1</span>  
     </dd>  
     <dt>  
       <label asp-for="Address2"></label>  
     </dt>  
     <dd>  
       <span>@Model.Address2</span>  
     </dd>  
     <dt>  
       <label asp-for="City"></label>  
     </dt>  
     <dd>  
       <span>@Model.City</span>  
     </dd>  
     <dt>  
       <label asp-for="ProvinceState"></label>  
     </dt>  
     <dd>  
       <span>@Model.ProvinceState</span>  
     </dd>  
     <dt>  
       <label asp-for="ZipPostalCode"></label>  
     </dt>  
     <dd>  
       <span>@Model.ZipPostalCode</span>  
     </dd>  
     <dt>  
       <label asp-for="Country"></label>  
     </dt>  
     <dd>  
       <span>@Model.Country</span>  
     </dd>  
     <dt>  
       <label asp-for="ContactNumber"></label>  
     </dt>  
     <dd>  
       <span>@Model.ContactNumber</span>  
     </dd>  
     <dt>  
       <label asp-for="Email"></label>  
     </dt>  
     <dd>  
       @if (!string.IsNullOrWhiteSpace(Model.Email))  
       {  
         <a href="mailto:@Model.Email">@Model.Email</a>  
       }  
     </dd>  
     <dt>  
       <label asp-for="WebSite"></label>  
     </dt>  
     <dd>  
       @if (!string.IsNullOrWhiteSpace(Model.WebSite))  
       {  
         <a href="@Model.WebSite" target="_blank">@Model.WebSite</a>  
       }  
     </dd>  
   </dl>  
 </div>   

Update GetContact Action Method

  • Change GetContrat Actin Method in ContactController.
    • After getting data object from ContactBusinessLogic, transform it into ContactVM object.
    • Pass contactVM object to view.
 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Threading.Tasks;  
 using Microsoft.AspNetCore.Mvc;  
 using WebApplicationCore.NetCore.BusinessLogic;  
 using WebApplicationCore.NetCore.Model;  
 using WebApplicationCore.NetCore.Models;  
 // For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860  
 namespace WebApplicationCore.NetCore.Controllers  
 {  
   public class ContactController : Controller  
   {  
     // GET: /<controller>/  
     public IActionResult Index()  
     {  
       return View();  
     }  
     public IActionResult GetContact(int id)  
     {  
       ContactBusinessLogic contactBL = new ContactBusinessLogic();  
       Contact contact = contactBL.GetContact(id);  
       ContactVM contactVM = new ContactVM  
       {  
         Address1 = contact.Address1,  
         Address2 = contact.Address2,  
         City = contact.City,  
         ContactId = contact.ContactId,  
         ContactNumber = contact.ContactNumber,  
         Country = contact.Country,  
         Email = contact.Email,  
         Name = contact.Name,  
         ProvinceState = contact.ProvinceState,  
         WebSite = contact.WebSite,  
         ZipPostalCode = contact.ZipPostalCode  
       };  
       return View(contactVM);  
     }  
   }  
 }  

Run Application in Debug Mode

  • Press F5 or Debug Menu >> Start Debugging or Start IIS Express Button on Toolbar to start application in debugging mode.
  • It will show Home Page in browser.
  • Type http://localhost:21840/Contact/GetContact/1 in address bar of browser and it will show Contact details of contact with Id 1.
  • Type http://localhost:21840/Contact/GetContact/2 in address bar of browser and it will show Contact details of contact with Id 2.
  • Type http://localhost:21840/Contact/GetContact/3 in address bar of browser and it will show Contact details of contact with Id 3.
  • Now we can notice that email and Web Site fields are showing as URLs. While there is no change in label names, they are still filed name. 

Use Data Annotation

  • Now lets add Display Attribute (from System.ComponentModel.DataAnnotations) with suitable heading to every field of ContactVM.
  • Run Application and Type http://localhost:21840/Contact/GetContact/1 in address bar of browser and it will show Contact details of contact with Id 1.
  • Now we can notice that we view is showing headings from ContactVM Display Attribute instead of field names.
  • Please refer ASP.NET Core 1.0 MVC Model for more details about Data Annotation.

 public class ContactVM  
   {  
     [Display(Name = "Contact Id")]  
     public int ContactId { get; set; }  
     [Display(Name = "Contact Name")]  
     public string Name { get; set; }  
     [Display(Name = "Address 1")]  
     public string Address1 { get; set; }  
     [Display(Name = "Address 2")]  
     public string Address2 { get; set; }  
     [Display(Name = "City")]  
     public string City { get; set; }  
     [Display(Name = "Province/State")]  
     public string ProvinceState { get; set; }  
     [Display(Name = "Zip/Postal Code")]  
     public string ZipPostalCode { get; set; }  
     [Display(Name = "Country")]  
     public string Country { get; set; }  
     [Display(Name = "Contact Number")]  
     public string ContactNumber { get; set; }  
     [Display(Name = "Email")]  
     public string Email { get; set; }  
     [Display(Name = "Web Site")]  
     public string WebSite { get; set; }  
   }  

Sunday, 28 August 2016

CRUD operations in ASP.NET Core 1.0 MVC Application Part 1

Let’s create Get Details page with our first custom Model, View and Controller. We are going to add new controller ContactController and its GetContact action method will display details of specified contact. We are going to use ASP.NET Core MVC Application from previous discussion Welcome to ASP.NET Core 1.0 MVC. We have not discussed database connectivity yet, so we are going to use a data mockup Model through static Contact List.

Create Data Model Project

  • Open existing Solution in Visual Studio 2015.
  • Now add new Client Library .NET Core project in Solution.
    • Open Add New Project Screen through Solution Context Menu >> Add >> New Project Or File >> New >> Project.
    • Select Class Library (.NET Core) Template through Installed >> Templates >> Visual C# >> .NET Core.
    • Name project as “WebApplicationCore.NetCore.Model”.
    • Set suitable location as “C:\ASP.NET Core\Welcome To .NET Core 1.0\ ASP.NET Core” (selected by default to solution root).
    • Click OK Button.
  • It will create a new class library project.
  • Rename Class1 as Contact and add required properties.
 public class Contact  
   {  
     public Contact()  
     {  
     }  
     public int ContactId { get; set; }  
     public string Name { get; set; }  
     public string Address1 { get; set; }  
     public string Address2 { get; set; }  
     public string City { get; set; }  
     public string ProvinceState { get; set; }  
     public string ZipPostalCode { get; set; }  
     public string Country { get; set; }  
     public string ContactNumber { get; set; }  
     public string Email { get; set; }  
     public string WebSite { get; set; }  
   }  


Create Business Logic Project

  • Now add new Client Library .NET Core project in Solution.
    • Open Add New Project Screen through Solution Context Menu >> Add >> New Project Or File >> New >> Project.
    • Select Class Library (.NET Core) through Installed >> Templates >> Visual C# >> .NET Core.
    • Name project as “WebApplicationCore.NetCore.BusinessLogic”.
    • Set suitable location as “C:\ASP.NET Core\Welcome To .NET Core 1.0\ ASP.NET Core” (selected by default to solution root).
    • Click OK Button.
  • It will create a new class library project.
  • Add reference to “WebApplicationCore.NetCore.Model” because we are going to use Contact Model Class in project.
    • Open WebApplicationCore.NetCore. BusinessLogic References >> Add References >> Reference Manager Screen >> Projects >> Solution >> Select WebApplicationCore.NetCore.Model.
    • Click OK Button.
  • Rename Class1 as ContactBusinessLogic and add method implementation for GetContact.
 public class ContactBusinessLogic  
   {  
     private static List<Contact> Contacts { get; set; } = new List<Contact>  
     {  
       new Contact { ContactId = 1, Name = "Imran Javed Zia", Address1 = "Street 1", Address2= string.Empty, City = "Lahore", ProvinceState = "Punjab", Country = "Pakistan", ZipPostalCode="12345", ContactNumber="+92123456789", Email="imran.javed@ijz.today", WebSite="http://www.ijz.today" },  
       new Contact { ContactId = 2, Name = "Person Test", Address1 = "Street Test 1", Address2= "Test Address 2", City = "New York", ProvinceState = "NY", Country = "USA", ZipPostalCode="10000", ContactNumber="+1123456789", Email="person.test@abc.com", WebSite="http://abc.com" },  
       new Contact { ContactId = 3, Name = "Test Person", Address1 = "Street Test 1", Address2= "Test Address 2", City = "Dallas", ProvinceState = "NY", Country = "USA", ZipPostalCode="75201", ContactNumber="+1987654321", Email="test.person@test.com", WebSite=string.Empty }  
     };  
     public ContactBusinessLogic()  
     {  
     }  
     public Contact GetContact(int contactId)  
     {  
       return ContactBusinessLogic.Contacts.FirstOrDefault(c => c.ContactId == contactId);  
     }  
   }  


Add Reference to WebApplicationCore.NetCore.BusinessLogic in WebApplicationCore.NetCore

  • Add reference WebApplicationCore.NetCore.BusinessLogic in WebApplicationCore.NetCore project.
    • Open Reference Manager Screen through WebApplicationCore.NetCore References Context Menu >> Add References.
    • Now in Reference Manager Screen >> Projects >> Solution >> Select WebApplicationCore.NetCore. BusinessLogic.
    • Click OK Button.
  • It will add reference to WebApplicationCore.NetCore.BusinessLogic along with WebApplicationCore.NetCore.Model

Add Contact Controller

  • Add new Controller.
    • Open Add New Item Screen through Solution Context Menu of Controller >> Add >> New Item >> Installed >> .NET Core >> MVC Controller Class.
    • Name it ContactController.cs.
    • Click OK Button.
  • It will add a new controller in Controller Folder.
  • Add GetContact Action Method implementations.
  • It is important to note that Home controller is default controller and Index method is treated as default method. So if we do not specify any controller in query string then Home controller is called similarly if action method is skipped in query string then Index method will be called. This behavior is defined in Route. We will discuss Routing in detail n future. 
 public class ContactController : Controller  
   {  
     // GET: /<controller>/  
     public IActionResult Index()  
     {  
       return View();  
     }  
     public IActionResult GetContact(int id)  
     {  
       ContactBusinessLogic contactBL = new ContactBusinessLogic();  
       Contact contact = contactBL.GetContact(id);  
       return View(contact);  
     }  
   }  


Add Contact GetContact View

  • Change _ViewImports.cshtml by including name space of Model. So we can access Contact Model without fully qualified name.
  • Add new Contact folder in View folder.
    • Open Context Menu of View >> Add >> New Folder.
    • Name it Contact.
  • Add new View.
    • Open Add New Item Screen through Solution Context Menu of Contact >> Add >> New Item >> Installed >> .NET Core >> MVC View Page.
    • Name it GetContact.cshtml.
    • Click OK Button.
  • It will add a new view in Contact Folder.
  • Change GetContact view implementations.
  • We are using Strongly Typed Views therefor we are declaring model type on start of view as @model Contact.
  • We can directly write value of a native type by using @Model.FieldMame, where @Model refers to model object passed to view and  and FieldName refers to any filed of that object.
  • Although we can use views with different name, even from different folder, yet by default view folder name should be similar to Controller name without Controller suffix. And Views must have same name as of related action method for default mapping. We will discuss views and its types in detail in future discussions.
 @model Contact  
 <h2>Contact</h2>  
 <div>  
   <dl class="dl-horizontal">  
     <dt>  
       Name  
     </dt>  
     <dd>  
       @Model.Name  
     </dd>  
     <dt>  
       Address1  
     </dt>  
     <dd>  
       @Model.Address1  
     </dd>  
     <dt>  
       Address2  
     </dt>  
     <dd>  
       @Model.Address2  
     </dd>  
     <dt>  
       City  
     </dt>  
     <dd>  
       @Model.City  
     </dd>  
     <dt>  
       ProvinceState  
     </dt>  
     <dd>  
       @Model.ProvinceState  
     </dd>  
     <dt>  
       ZipPostalCode  
     </dt>  
     <dd>  
       @Model.ZipPostalCode  
     </dd>  
     <dt>  
       Country  
     </dt>  
     <dd>  
       @Model.Country  
     </dd>  
     <dt>  
       ContactNumber  
     </dt>  
     <dd>  
       @Model.ContactNumber  
     </dd>  
     <dt>  
       Email  
     </dt>  
     <dd>  
       @Model.Email  
     </dd>  
     <dt>  
       WebSite  
     </dt>  
     <dd>  
       @Model.WebSite  
     </dd>  
   </dl>  
 </div>  


Run Application in Debug Mode

  • Press F5 or Debug Menu >> Start Debugging or Start IIS Express Button on Toolbar to start application in debugging mode.
  • It will show Home Page in browser.
  • Type http://localhost:21840/Contact/GetContact/1 in address bar of browser and it will show Contact details of contact with Id 1.
  • Type http://localhost:21840/Contact/GetContact/2 in address bar of browser and it will show Contact details of contact with Id 2.

Sample Source Code

We have placed sample code for this session in "CRUD operations in ASP.NET Core 1.0 MVC Application Part 1_Code.zip" in https://aspdotnetcore.codeplex.com/SourceControl/latest CodePlex repository.

CRUD Operations in AP.NET Core 1.0 All Parts

CRUD operations in ASP.NET Core 1.0 MVC Application Part 1
CRUD operations in ASP.NET Core 1.0 MVC Application Part 2
CRUD operations in ASP.NET Core 1.0 MVC Application Part 3
CRUD operations in ASP.NET Core 1.0 MVC Application Part 4
CRUD operations in ASP.NET Core 1.0 MVC Application Part 5
CRUD operations in ASP.NET Core 1.0 MVC Application Part 6
CRUD operations in ASP.NET Core 1.0 MVC Application Part 7 
CRUD operations in ASP.NET Core 1.0 MVC Application Part 8

Tuesday, 23 August 2016

ASP.NET Core 1.0 MVC Project Structure Overview

Let’s discuss structure of ASP.NET Core MVC Web Application Project. We are going to use project created in our last discussion Welcome to ASP.NET Core 1.0 MVC. We have following major areas:
  • Properties
  • References
  • wwwroot
  • Dependencies
  • Controllers
  • Views
  • Program.cs
  • Startup.cs
  • Configuration Files



Properties

Properties section contains launchSettings.json file which has project settings. Although it can be edited directly, yet it is generally edited by other interfaces like project properties.

References

References section contains all DLL references added to project. Visual Studio 2015 shows added references in groups. For this template, Visual Studio adds .NET Core Application related DLLs.


We can add new references directly or through NuGet Packages.
  • To add reference from other project of same solution, Open Reference Manger Screen from Context Menu of Project References >> Add References. And then on Reference Manager Screen >> Projects >> Solution >> Select Project Name.
  • To add reference from existing DLLs, Open Reference Manger Screen from Context Menu of Project References >> Add References. And then on Reference Manager Screen >> Assemblies >> Browse >> Select Required Assemblies to be added.
  • To add references from NuGet, Open NuGet Manger Screen from Context Menu of Project References >> Manage NuGet Packages. And then on NuGet Manager Screen >> Browse >> Search and Install Required Assemblies to be added.
  • Open Package Manger Console through Tools >> NuGet Packet Manger >> Package Manger Console and run install command "Install-Package FullPackageName".

wwwroot

wwwroot is a special folder which contains all the static resources like css, images, JavaScript and included libraries. Visual Studio Template uses wwwroot name by default, but we can change it as per requirements.



Dependencies

Dependencies section contains list of third part dependencies added to project through Bower. By default this template adds: bootstrap, jquery, jquery-validation and jquery-validation-unobtrusive.


We can add new bower through Manage Bower Packages.
  • To add new bower Open Manage Bower Packages Screen from Context Menu of Project Bower >> Manage Bower Packages. And then on Manage Bower Packages Screen >> Browse >> Search and Install Required Packages to be added.

Controllers

Controllers folder contains controllers added to application. It is not necessary to add controllers to this folder or to create this folder, but it is one of practices to add controllers to this folder or its subfolders. This templates add HomeController by default with Index, About and Contact action methods.


Views

Views folder contains views in 3 categories:
  • Controller Views
  • Shared Views
  • Special Views

Controller Views

All the views related to a controller have views in a folder named to that controller. This example Home folder contains views for each action method of HomeController.

Shared Views

Shared views folder contains: _Layout and Error view. _Layout view contains layout of application and in term of ASP.NET it replaces Master Page. Error view contains the implementation of error page which is displayed to end user in case of any error.

Special Views

While there are 2 special views in this template: _ViewImports and _ViewStart. _ViewImports contains the list of imports for all views. And ViewStart contains generic page initializations like layout globally.



Program.cs

Program.cs contains Main method, which is starting point of application. It initializes WebHostBuilder instance and starts the host environment. We can set web server related configurations in this area. We will have complete detailed discussion on this item separately.


Startup.cs

Startup.cs contains main implementation for Environment Startup. This class not only initialize basic environment configurations and request pipeline but also other features like logging, error page and routing. We will have complete detailed discussion on this item separately.


Configuration Files

This template creates different configuration files of .config and .json type at root of project:
  • appsettings.json 
  • bundleconfig.json 
  • project.json
  • web.config
These files contains application settings, configurations related to bundling and minification and project settings. We can also use ini files, environment variables, command line arguments and even custom configuration provider. We will have complete detailed discussion on this item separately.




Wednesday, 17 August 2016

What is .Net Core 1.0

.NET Core is a latest and emerging development platform for web applications, services and console applications by Microsoft. It is important to note that it was initially named .NET 5.0 or .NET Core 5.0. By features, it is sub set of .NET 4.6 framework. It offers following matchless features:
  • Open Source
  • Cross Platform (Windows, Linux and Mac)
  • Modular Platform
  • Modern
  • Evolving

Open Source

.NET Core is open source, which means it is free of cost and its source code is available. We can get advantages of community work supported by Microsoft.  We can not only review code, but can add new features or fix bugs as per needs (as per open source license).

Cross Platform (Windows, Linux and MacOS)

.NET Core is cross platform. So you can build and execute same application code on any operating system of your choice. At the moment supported operating systems are Windows, Linux and MacOS.

Modular Platform

.NET Core has been built to be modular platform, so you have to pay for play only. This decision has been made to make .NET Core simpler and easier to implement for cross platforms and to make it lightweight and faster.

Modern

.NET Core has provided many modern features like generics, LINQ, asynchronous programming. And many other advancements like WCF, UWP, F#, Visual Basic and other language support are under process.

Evolving

.NET Core is a new implementation from scratch. It is in its initial phases and it is not complete yet. At the time of this atrial, it only supports C# while Visual Basic and F# are not supported yet, but soon they will be part of .NET Core (in couple of months approximately). Similarly, SignalR support has not been delivered yet. It only allows development for web applications, services and console applications while other development tools have not been announced yet.

Advantages of .NET Core 1.0

New exciting features are going to open new paradigm for .NET developers to create applications having following advantages:
  • Lightweight
  • Performance
  • Scalability
  • Easy to Learn and Easy to Manage
  • Standardized
  • Cost Effective

Lightweight

Due to modular platform design, we include minimum number of modules as per requirements. This make overall package lightweight.

Performance

Being lightweight and having better implementation, .NET Core application is 3 to 8 times faster than its competitor.

Scalability

It is lightweight, having high performance. It is claimed that an application implemented in .NET Core can server more than 20 time of requests per second. Please refer to open source benchmarking project and its details at https://github.com/aspnet/benchmarks.

Easy to Learn and Easy to Manage

.NET Core is very simple for both of new and legacy developers. You have a lot of resources available online.

Standardized

.NET Core provides a preplanned standardized infrastructure through .NET Standard Library. This Standardized infrastructure is base for unified development of cross platform applications.

Cost Effective

.NET Core is going to open a new arena. It is going to be cost effective by many ways.
  • It is cross platform, you can chose any operating system of your choice, even a free one.
  • Think about an application which has to be available on all major platforms. For example, our company has a web application product, now we may have single code repository for all platforms. It will reduce development cost directly.
  • We have high performance applications with huge scalability means better ROI. Now we can either have more services from same hardware resources or we can get same services with very fewer hardware resources.
  • It is open source, so it is free and we are going to have lot of technical resources available. Although all IDEs like VS 2015 are not free but we can chose one of many options like: Visual Studio Code or use any editor of your interest even Notepad with command line through .NET Core SDK.

Cautions while choosing .NET Core 1.0

Obviously, we are going to consider .NET Core as first choice as development framework. But consider following before making final decision:
  • At the moment .NET Core does not have features like: WPF, WCF, WF, Web Forms, Win Forms, and SignalR.
  • It also does not have support for languages: VB.NET, F#.
  • If our project relies on third party components then make sure those are available for .NET Core too.
  • Please refer to road map https://github.com/aspnet/Home/wiki/Roadmap for more details about what is coming in features.
  • It does not support features like Code Access Security (CAS).

What is .Net 4.6

.NET 4.6 is a latest full .NET Framework and it is main development platform for windows. It is a mature platform having many features including famous features like WPF, WCF, WF, ASP.NET (Web Forms), ASP.NET MVC, Win Forms, SignalR, Console Applications and many more. It has following characteristics:
  • It is successor of .NET 4.5 following a steady path starting from .NET 1.0 since 2002.
  • It is not open source and proprietary of Microsoft.
  • It is not cross platform.
  •  It has huge set of features and supported languages.

Monday, 15 August 2016

Welcome to ASP.NET Core 1.0 MVC

Let’s create our first ASP.NET Core MVC Web Application. We assume that we already have Visual Studio 2015 Update 3 and .NET Core 1.0.0 - VS 2015 Tooling Preview 2. If you have not installed .NET Core yet then I may recommend you to follow our initial discussion How to install .NET Core 1.0. Alternatively you can follow Microsoft Official Site directly.

Create a new Solution

  • Open Visual Studio 2015.
  • Open New Project Screen through menu File >> New >> Project.
  • Select Blank Solution through Installed >> Templates >> Other Projects >> Visual Studio Solutions.
  • Name solution as “ASP.NET Core”. Set suitable location as “C:\ASP.NET Core\Welcome To .NET Core 1.0\”.
  • Click OK Button.

Add a new ASP.NET Core Project in Solution

  • Open New Project Screen through Solution Context Menu >> Add >> New Project Or File >> New >> Project.
  • Select ASP.NET Core Web Application (.NET Core) through Installed >> Templates >> Visual C# >> .NET Core.
  • Name project as “WebApplicationCore.NetCore”.
  • Set suitable location as “C:\ASP.NET Core\Welcome To .NET Core 1.0\ ASP.NET Core” (it is default location depending on solution path).
  • Click OK Button.
  • Select “Web Application” template from Template Window. And leave other options unchanged.
  • Click OK Button.
  • It will create new ASP.NET Core MVC Web Application.

Run Application in Debug Mode

  • Press F5 or Debug Menu >> Start Debugging or Start IIS Express Button on Toolbar to start application in debugging mode.
  • It will show Home Page in browser.
  • Click About Menu Item to open About page.
  • Click Contact Menu Item to open Contact Page.

Sample Source Code

We have placed sample code for this session in "Welcome to ASP.NET Core_Code.zip" in https://aspdotnetcore.codeplex.com/SourceControl/latest CodePlex repository.

How to install .NET Core 1.0

Let’s prepare our development environment for .NET Core 1.0 on Windows platform. We have lot of options available to prepare development environments:
  • Use Visual Studio 2015 with Update 3 using .NET Core 1.0.0 - VS 2015 Tooling Preview 2.
  • Visual Studio Community using .NET Core 1.0.0 - VS 2015 Tooling Preview 2.
  • Visual Studio Code with Command Line using .NET Core SDK for Windows.
  • Any Editor with Command Line using .NET Core SDK for Windows.

Our Recommendations

We are going to use Visual Studio 2015 with Update 3 using .NET Core 1.0.0 - VS 2015 Tooling Preview 2. Please follow these steps:
  • Download and install Visual Studio 2015 Update 3. Alternatively update through Extensions and Updates. For this open Tools Menu >> Extensions and Updates >> Updates >> Product Updates >> Visual Studio 2015 Update 3.
  • Download and install NET Core 1.0.0 - VS 2015 Tooling Preview 2.

Visual Studio 2015 with Update 3

If you already have Visual Studio 2015 then you need to upgrade Visual studio 2015 with update 3. Please refer to following to download and to update https://go.microsoft.com/fwlink/?LinkId=691129. We can also download trial version of Visual Studio 2015 from https://www.microsoft.com/en-us/download/details.aspx?id=48147.

Visual Studio Community

Visual Studio Community is a community supported IDE. We can download it from https://go.microsoft.com/fwlink/?LinkId=691978&clcid=0x409 free of cost. Please refer to https://beta.visualstudio.com/free-developer-offers-vs/ for more details. And please refer to https://www.microsoft.com/en-us/download/details.aspx?id=48146 for technical details.

Visual Studio Code

Visual Studio Code is a free open source and cross platform editor. We can download it from https://go.microsoft.com/fwlink/?LinkId=691978&clcid=0x409 free of cost. Please refer to https://beta.visualstudio.com/free-developer-offers-vs/ for more details.

.NET Core 1.0.0 - VS 2015 Tooling Preview 2

.NET Core 1.0.0 - VS 2015 Tooling Preview 2 can be downloaded from https://go.microsoft.com/fwlink/?LinkID=824849 free of cost.

Microsoft Official Repository

We can also follow official page https://www.microsoft.com/net/core to get more details, latest updates and other installers for Linux and Mac platforms.