ASP.NET Core 2.x - Getting Started
ASP.NET Core is a cross-platform, high-performance, open source framework for building modern, cloud-based, Internet-connected applications. It all sums up to:
- ASP.NET Core can be used to build web apps and services, IoT apps, and mobile backends.
- You can develop it on any OS, say Windows, Linux or MacOS
- You can deploy the code on the cloud, be it AWS or Azure or Google Cloud or any local server.
- In the new ASP.NET Core, you have the choice to chose between full blown .NET framework or .NET Core
When you get started with ASP.NET Core, the question that comes to your mind is what is so different about it? Well, a lot has changed.
ASP.NET Core can be used to build web applications on Windows, macOS, or Linux. This is truly open source and cross platform. You can even go ahead and use it in command line with any text editor (I prefer Visual Studio Code because of its cool features).
ASP.NET 4.X is a well tested and mature framework that provides the services needed to build enterprise-grade, server-based web apps only on Windows.
|ASP.NET Core||ASP.NET 4.x|
|Build for Windows, MacOS, or Linux||Build for Windows|
|Razor Pages is the recommended approach to create a Web UI as of ASP.NET Core 2.x. See also MVC, Web API, and SignalR.||Use Web Forms, SignalR, MVC, Web API, WebHooks, or Web Pages|
|Multiple versions per machine||One version per machine|
|Develop with Visual Studio, Visual Studio for Mac, or Visual Studio Code using C# or F#||Develop with Visual Studio using C#, VB, or F#|
|Higher performance than ASP.NET 4.x||Good performance|
|Choose .NET Framework or .NET Core runtime||Use .NET Framework runtime|
When to chose .NET Core?
- You have cross-platform needs.
- You are targeting microservices.
- You are using Docker containers.
- You need high-performance and scalable systems.
- You need side-by-side .NET versions per application.
- Your app currently uses .NET Framework (recommendation is to extend instead of migrating).
- Your app uses third-party .NET libraries or NuGet packages not available for .NET Core.
- Your app uses .NET technologies that aren't available for .NET Core.
- Your app uses a platform that doesn’t support .NET Core.
Lets get started
In this tutorial you will learn to:
- Installing the prerequisite SDK
- Using .NET CLI
- Creating a new project
- Running the new project
1. Installing the prerequisite SDK
Before we get started make sure that .NET 2.2 SDK is installed.
At the time of this writing .NET Core 3.0.0 is in Preview 5. I will be using 2.2 SDK in rest of this tutorial.
Once you click on .NET Core downloads, select 2.2.5 version and install the downloaded file. Once that done, step 1 is complete. Let us proceed to step 2.
2. Using .NET CLI
The .NET Core command-line interface (CLI) is a new cross-platform toolchain for developing .NET applications.
For 2.2 Version, we can use the following commands:
3. Creating a new project
At the time of writing the CLI provides the following ways to create a new project:
In this tutorial we are focussing on ASP.NET Core Web App. Open a command shell, and enter the following command:
dotnet new webapp -o aspnetcoreapp
Congratulations 🎉🎉🎉🎉 You have created you first ASP.NET Core project.