CodeDigest.Com Logo
Featured:

Learn .Net Core in 10 Minutes

.Net Core is a platform independent, modular and open source version of .Net framework. It is a complete re-write of .NetFramework with new CLR, Base Class Libraries for developing cross platform and cloud optimized applications. It is a modular framework, meaning developers can include only required package to build their applications. All the packages are delivered via Nuget package manager.

In other words, .Net Core framework packages can be included in your application privately or the framework can be installed on the machine (similar to full .NetFramework). Current version of .Net Core as of this writing is .Net Core 2.0 and the first official version is .Net Core 1.0. It is also delivered as complete installer package if required.

Repository: https://github.com/dotnet/core

.NetFramework vs .Net Core

  • Applications developed on .NetFramework can run only on Windows OS while .Net Core applications can be run on multiple Operating Systems like Mac and multiple flavors of Linux. Though, we have Mono framework for running .Net application in Linux but it is not a complete and stable framework to run .Net application in Linux environments.

  • Applications developed using .Net Core runs faster since .Net Core is a modular framework.

  • Like Full .NetFramework, .Net Core is also fully supported by Microsoft.

  • Unlike full .NetFramework, .Net Core is granularly packaged and they are available as Nuget packages.

.Net Core Supported Features

  1. .Net Core currently supports Asp.Net Core web applications using MVC framework (called Asp.Net Core MVC). No WebForms Development.

  2. Currently supports only C#. Full VB support is planned in a future update.

  3. Supports development of command-line application.

  4. No Desktop application development, Workflow and WCF service development. WCF client library for consuming SCF service is supported

  5. Supports REST API development using Web API.

  6. Supports SignalR applications development

  7. Includes Entity Framework Core for ORM support.

  8. Supports LINQ, Generics and Async features.

Tools Support

  1. Visual Studio on Windows can be used to develop .Net Core applications. .Net Core 1.0 is released along with Visual Studio 2015 Update 3. The latest version Visual Studio 2017 has full support for developing .Net Core 2.0 applications.

  2. A new IDE called Visual Studio Code can be used to develop .Net Core applications in Mac and Linux OS.

  3. Includes a command line tool called “dotnet” or dotnet CLI to perform all activities like build, run from command line interface similar to open source platforms.

 

Quick Start

Pre-Requisite

  • All required package can be downloaded from here.

  • Need Visual Studio 2015 Update 3 or Visual Studio 2017 for full support. You can also use the free developer version called Visual Studio Community from here.

  • Download and install latest version of .Net Core 1.1 or 2.0 framework from here.

Visual Studio Tools for .Net Core Development

Download Visual Studio 2015 Tools from here to get tooling support for .Net Core development using Visual Studio 2015 Update 3.

Creating New Project

  1. Open Visual Studio 2015 (Update 3)  or 2017.

  2. Go to File > New > Project… Select “ASP.Net Core Web Application(.NET Core)” template and click OK.

  1. This will bring another dialog to pick the pre-configured template to start working with Asp.Net Core application. Select “Web Application” and click Change Authentication and select “Individual User Accounts". Click OK.

This will create a project with default controller implementation with Authentication to start development. All the pre-configured Nuget packages will be restored and the final solution explorer will look like,

  1. Press F5 and you will see the default page created by Visual Studio project template.

Note – By default, the application will use Kestrel webserver to host the application.

 

Using dotnet Command Line Interface Tool (dotnet CLI)

The .Net Core sdk is packed with number of commands to work with .Net core applications from command prompt. Some of them are build, clean, run, restore etc.

For example, to run a .Net core application from command prompt we can use dotnet run.

To do this, Open command prompt, go to the directory where project.json file is located. It should be located at src/[projectname] folder. Type dotnet run and press enter. Refer the below image.

This command will start and host the application using Kestrel webserver. By default Kestrel will listen the port 5000 for application request. Visiting http://localhost:5000 you will see the .net core application up and running similar to above.