In this ASP.NET Core tutorial for beginners, we will be discussing in detail about the ASP.NET Core framework, installation, and setup, creating and running a “hello world” application in asp.net core.
ASP.NET Core is a cross-platform, open-source framework for building modern cloud-based applications.
Its a redesign of the previous version of ASP.NET 4.x for that reason it was initially called ASP.NET 5 but later renamed to ASP.NET Core.
Below are the benefits and features offered by one of the most popular software development framework:
- Cross-Platform: ASP.NET Core applications can be developed and run across multiple platforms – macOS, Windows, and Linux.
- Hosting: They can be hosted on IIS, Apache, Docker, and also self-hosted.
- IDE: You can use visual studio code, visual studio, sublime code editor.
- Programming Model: It offers a unified programming model for MVC and Web API. Both MVC Controller and Web API Controller class inherit from the same Controller base class and returns IActionResult.
- Dependency Injection: ASP.NET Core comes with built-in support for DI.
- Testability: As this framework comes with built-in dependency injection and unified programming model, UNIT testing for the .net core applications is easy.
- Community Support: As the ASP.net core framework is open source and it has great community support. It is continually evolving as the vast community behind it is suggesting ways to improve it and helping in fixing bugs and problems.
- MVC knowledge would be helpful but not required.
- IDE: Visual Studio, VS Code, Sublime Text (Any one of these)
- .NET Core SDK (Software Development Kit)
In this asp.net core tutorial, we are going to use the VS Code as an editor for our software development using ASP.NET Core applications.
For installing Visual Studio Code, please visit – https://code.visualstudio.com and download the respective version – macOS, Windows, Linux as per your development machine.
Download the SDK from Microsoft’s official website – https://dotnet.microsoft.com/download
At the time of writing this article, the latest stable version is .NET Core 3.1.
Now, the development machine is ready, let’s begin creating our first ASP.NET Core application and display “Hello World” on the web browser.
Open cmd by going to run (window + R) and enter the command given below. This command will create a new web app named aspnetcoreapp.
dotnet new webapp -o aspnetcoreapp
Now for running your app, use the following commands:
cd aspnetcoreapp dotnet watch run
After the above command indicates that the app has started, open your web browser, and navigate to:
So now, you will be presented with a Welcome page. In order to display the “Hello World” message, Open Index.cshtml file under the Pages folder.
Modify the file as shown in the screenshot and then save the page.
Once, done with all these actions, refresh the page http://localhost:5001 and verify your changes as shown below.
So far in this asp.net core tutorial, you have learned:
- ASP.NET Core is an open-source, cross-platform framework for building modern applications.
- It offers a wide range of features, few of those are cross-platform support, unified programming model, large community support, etc.
- All you need is one of the IDE along with .NET Core SDK to get started.
- Build your first program or hello world application using asp.net core framework.
We are concluding with the hope that you enjoyed going through this asp.net core tutorial.
👉 Please share it with your friends interested in learning asp.net core.
👇 Check these books on ASP.NET Core 👇