Getting Started With ASP.NET Core - Part Two

Introduction

 
Read the previous ASP.NET Core part of this article using the below link before reading this article.
Definition
 
ASP.NET Core is a cross-platform and open-source framework. ASP.NET Core supports Windows, Mac or Linux operation system. It is used to develop modern, cloud-based and high-performance web applications.
 

Difference between ASP.NET Core and ASP.NET

 
These are the following differences between ASP.NET Core and ASP.NET.
 
 ASP.NET Core
ASP.NET
It supports Windows, macOS, or Linux.
It supports only Windows.
Supports .NET Core and .NET Framework.
Supports only .NET Framework.
Razor page is recommended to create application using ASP.NET Core. We can use MVC, Web API, and SignaIR
We can use Web Form, SIgnaIR, MVC, Web API, WebHooks or Web Page.
Higher performance than ASP.NET
It has good performance.
It supports multiple versions in a machine.
It supports only one version in a machine.
Develop with Visual Studio, Visual Studio for Mac, or Visual Studio using C# or F#.
Develop with Visual Studio using C#, VB or F#.
We can host the ASP.NET Core applications not only on IIS but they can be self-hosted or use Nginx web server, on Linux.
We can host the ASP.NET applications only on IIS.
Here wwwroot folder is available for static files.
Here wwwroot folder is not available.
Inbuilt Dependency Injection (DI) support for ASP.NET Core.
We use to have separate DI containers.
 

.NET Standard

 
Shared Application Program Interface (API) is called .NET Standard. It is a Base Class Library (BCL) for different .NET Platforms. Enables developers to produce portable libraries that are usable across .NET implementations, using same set of APIs. Full .NET Framework, .NET Core, Xamarin and all others sharing the .NET Standards.
 
ASP.NET Core
 
We have multiple class libraries for the different platform of .Net and it is very difficulties to share the code between runtimes as the code you write for our runtime might not work in another runtime because it does not have the APIs that we need. .NET Standard defines a uniform set of BCL APIs for all .NET implementation to implement, independent of workload.
 
ASP.NET Core
 

Creating first ASP.NET Core Application

 
We are going to create the first ASP.NET Core application using Visual Studio 2019. We have explained how to setup Visual Studio 2019 in the previous part of this article.
 
Step 1
 
Open the Visual Studio 2019, Go to and click Create a new project.
 
ASP.NET Core
 
Step 2
 
We can find the different type of projects on the screen. Go to search ber type and select the first one which has C# language, this search option is a new feature in Visual Studio 2019.
 
ASP.NET Core
 
Step 3
 
Click Next after selecting the Asp.NET Core Web Application. Give the Project Name, Location, Solution name. The project name should be related to your project concept. Finally, click Create.
 
ASP.NET Core
 
Step 4
 
We can select the template in this step. Select the .NET Core Framework, ASP.NET Core version (ASP.NET Core 2.1). Finally, select the Web Application and uncheck the “Configure for HTTPS” then click the create.
 
ASP.NET Core
 
Step 5
 
Our First ASP.NET Core application created after clicking the Create button. WE can see the basic folder structure looks below.
 
ASP.NET Core
 
Step 6
 
Build the ASP.NET Core application and run it. We can see the looks like below screenshot for first ASP.NET Core application.
 
ASP.NET Core
 

Folder Structure Explanation

 
Dependencies
 
Dependencies is the first one in the folder structure. Analyzer, NuGet, SDK are three important part in the dependencies. We called “References” in ASP.Net or ASP.NET MVC but in ASP.Net Core we called Dependencies. NuGet and SDK are very important part of ASP.Net Core, those are used to add asp.net core and build and run the applications.
 
ASP.NET Core
 
Properties
 
Properties contain the “launchSettings.json” file. All the necessary settings are defined in this JSON file for launch our application. There are three important launch settings, those are iisSettings, profiles, application (FirstCoreApp). Commonly we are mentioning the application URL, environment variable, windows, anonymous authentication in the launch settings.
 
ASP.NET Core
 
ASP.NET Core
 
wwwroot
 
wwwroot is the web root folder in ASP.NET Core. All the static files are stored in the wwwroot. We can access the static files directly with a relative path to that root. Static files, such as HTML, CSS, images, and JavaScript.
 
ASP.NET Core
 
We can access the static files directly with a relative path to that root, for example, if we go the URL http://localhost:53388/css/site.css we can see the site.css file content. We can not directly access the files except wwwroot folder.
 
ASP.NET Core
 
Appsettings
 
Appsettings.json is like web.config in ASP.Net Core application. We will discuss “Program.cs, Startup.cs” in details in the next part of the article.
 

Conclusion

 
This article explained the difference between ASP.NET core and ASP.NET, .NET Standard, First ASP.NET Core application, and ASP.NET Core application folder structure. I hope this really helps new learners, students, and freshers.