.net core installation and first experience

.net core installation and first experience

.net core installation and first experience

As a new generation technology of Microsoft, .net core has great advantages in the development of cross-platform and microservices, and it is also closer to modern coding habits. Long after version 2.0 was released, I finally decided to learn and experience recently.


As a .net programmer, the most convenient development tool is of course visual studio. Although .net core can be developed in tools such as vs code, I still use visual studio as a development tool.

First install visual studio 2017, download and install by yourself here, and check .net core during installation.

After the installation is complete, open the console to verify whether the installation is successful. Enter at the console:

dotnet --version

If the installation is successful, the version number of the current .net core will be displayed

Hello world

No matter how complicated the program, our best starting point is to complete a hello world example. We open vs, create a new console application (.net core), enter the project name, and then confirm.

The entry of the program is still the static main method of the Program class. In this method, the code for outputting Hello world has been completed for us:

class Program
    static void Main(string[] args)
        Console.WriteLine("Hello World!");

Run the program, you can see the console output Hello World´╝üstring.

Use ASP.NET Core

Next we create a ASP.NET Coreproject to experience it. We choose to create an empty website. After the project is created, there are two .cs files in the root directory, namely Program.cs and Startup.cs files.

Compared with the traditional ASP.NET website, the ASP.NET Corewebsite is run as a console application. A web host program is created through the console to process web requests. This is similar to node.js and golang.

When we run this project, a browser will open, and the Hello world!string will be displayed in the browser .

Reference: https://cloud.tencent.com/developer/article/1511851 .net core installation and first experience-Cloud + Community-Tencent Cloud