Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

ASP.NET Core Tutorial for Beginners with Examples in C#

In this asp.net core tutorial, you will learn the history of .NET Platform, .NET and .NET Core, What .NET Core does not support, .NET and .NET Core Compilation, Rosyln, CoreCLR, RyuJIT and .NET CLI. Keep reading on What’s the difference between .NET Core Vs .NET Framework.

ASP.Net Core Tutorial

ASP.Net Core is the latest development framework from Microsoft. It’s a complete design of existing asp.net 4.x with architectural changes that make it a linear, modular and high-performance framework.

History of .NET Platform

.NET Framework

  • A development platform for building web applications, services, and mobile applications.
  • It contains a common language runtime (CLR) and, the .NET Framework class library that support an extensive range of technologies.
  • Runs on Windows OS only.
  • The most recent official release of .NET is 4.7.2

.NET Core Framework

  • Modular and smaller implementation of .NET.
  • Cross-platform and Open Source. So we can run it on Windows, Linux, and Mac operating systems.
  • It supports containers such as Dockers, Kubernetes, etc.
  • It supports Microservices Architecture.
  • Optimized for high performance and scalability.
  • It supports Cross-platform development tools – VS Code, Dot Net CLI.
  • It built for the next 10 years of software development.
  • In a couple of years, .NET Core will replace all the implementation of .NET.

What .NET Core does not support?

  • WPF
  • Winforms
  • WebForms
  • ASMX Services
  • WCF Services
  • WWF
  • LINQ to SQL

So, these are the things actually we can not develop on top of .Net Core but It doesn’t mean that I can not consume the WCF like ASMX services in a .Net Core application. We can consume but can not develop. And Microsoft team is constantly working on WCF support as well so soon you will get the support of WCF on top of .Net Core.

.NET and .NET Core CLI Compilation

.NET Compilation:

.NET Core Compilation:

Roslyn – .NET Core Compiler

  • A new .NET Compiler Platform which is based on compiler “As-a-Service”.
  • An open-source C# and Visual Basic compiler with rich code analysis APIs.
  • It enables building code analysis tools with the same APIs that are used by Visual Studio.

CoreCLR

  • Runtime implementation of .NET Core.
  • A group of technologies that are fundamental to the runtime, such as RyuJIT, Garbage Collector, native interop, and many other components.
  • The CoreCLR is cross-platform and CLR is not.

RyuJIT (Just-In-Time compiler)

  • Next-generation Just-In-Time (JIT) compiler for .NET Core.
  • Supports High-performance JIT architecture, focused on high throughput, JIT compilation.
  • The new JIT is twice as fast, meaning apps compiled with RyuJIT start-up to 30 percent faster.

.NET CLI

  • A toolchain for building, developing and publishing .NET Core based Apps.
  • It supports various commands.
  • It supports the Installation of Packages.
  • Cross-platform supports.

.NET CLI Commands

  • dotnet new : (Scaffolds a minimal app) To create a .net core based application.
  • dotnet restore : (Restore packages for the project)
  • dotnet run : (Compiles and run the app)
  • dotnet build : (Compiles to IL)
  • dotnet build -native : (Compiles a single executable)
  • dotnet dosomethingcool : (Build your own command)

.NET Core Compilation and CLI

So this is a complete compilation of our code using the .Net Core CLI.

.NET CLI Application Template

Enter command dotnet new -l

So let me show the way how these .NET CLI is working here. But first of all, you should know how to prepare your system. Make sure everyone has downloaded the visual studio on your machine just sharing the link from where you can download the visual studio from the official web site https://visualstudio.microsoft.com/. From there you can download visual studio 2017/19 community edition (free).

In the same way, you can download Node.js from the https://nodejs.org/en/ link and SQL Server 2017/19 express edition as well. As an IDE you can download Visual Studio Code and download the .NET Core SDK.

Verify the Environment 

The environment you can verify using the command prompt and entering the command dotnet-v, dotnet –version

Here also you can check all the available templates using the command dotnet new -l. 

So you can see the available templates here which you can use for creating your .net core based application such as console application, class library, etc using .net core CLI. Now let me show the way how you can create the console application using the .NET CLI.

Step1: Enter a command dotnet new console, It will create the console application as shown below;

Step2: After successfully created the project, open the project in the Visual Studio Code as shown below. Also, you can open the same project in Visual Studio as well.

.NET Standard Library

We have the three extensions of the .NET as we have .Net Framework, .NET Core and Xamarin. But now the requirement is how we can share the code across these three implementations. For code sharing, we have here the .NET Standard Library. So using this library we can share the code among all these three implementations of .NET.

So just create a .Net Standard Library and you can use it with the Xamarin, .Net Core and the .Net Framework project. Let me share the way how we can share the code here by following the below steps:-

Step1: Open the Visual Studio 2017/19 and create a new project with a blank solution named CodeSharing as shown below:-

Step2: Now create a new MVC 5 project under this solution by selecting a .NET framework 4.6.1.

Step3: Now create the ASP.Net Core web application (Model View Controller) project by selecting ASP.NET Core 2.1 named WebAppCore.

Step4: Next you need to create a new Class Library (.Net Standard) named DomainModel.

Step5: Now create a User class and add properties like UserId, Name, etc.

Step6: Then add a reference to the MVC5 project and WebAppCore project. Build the solution.

So it is the style that we can use for code sharing between the different versions or you can say different implementation of the .NET based application. The same .Net Standard library we can access in Xamarin as well.

Download Source Code

Conclusion

I hope you liked this article on the asp.net core tutorial for beginners. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

The post ASP.NET Core Tutorial for Beginners with Examples in C# appeared first on DotNetTec.



This post first appeared on Asp Dot Net Tricks And Tips, Dot Net Coding Tips, Google Maps API Developer, please read the originial post: here

Share the post

ASP.NET Core Tutorial for Beginners with Examples in C#

×

Subscribe to Asp Dot Net Tricks And Tips, Dot Net Coding Tips, Google Maps Api Developer

Get updates delivered right to your inbox!

Thank you for your subscription

×