An Overview Of ASP.NET Core

What is Asp.Net Core

ASP.NET Core is now completely rewritten following the earlier versions that work on the .NET Framework. ASP.NET was developed with the main focus to make it cross-platform! Yes, ASP.NET Core is now cross platform. It has gained popularity in a very short time for modern day web development. On the go, cloud development with configurations made easy, along with a self-hosting process as well as IIS and many more features added to ASP.NET Core which makes it stand tall!

Cross Platform!

Yes! you read it right, ASP.NET Core is now cross platform. The ASP.NET Core CLR now has WPF & WinForms. It is built to code once and run on any platform. We can now have the .NET framework installed on Linux, Unix, or OSX.

ASP.NET Core

.NET Core CLR has joined the open source community and is on GitHub. Now, anyone can contribute on GitHub for .NET Core. ASP.NET Core applications can run on earlier .NET frameworks and also on .NET core, which is a great benefit for the developers. .NET Framework 4.6 is the same .NET that we have been using and continue to develop in the same way. .NET Core gives us a platform to generate cross-platform solutions. However, .NET 4.6 is stable and .NET Core are still in progress.

Merged stack MVC & Web API

Now, this seems interesting... What? MVC & Web API merged!! Yes, it is! In ASP.NET Core, we now have the merged stack of MVC and API and moreover, Webforms is completely gone!
 
Earlier, we were required to add more than one Web projects - one for MVC and one for Web API. But in ASP.NET Core, we only need to have one project. Multiple inbuilt tools are being used with .NET Core to build web applications with ease like NPM for tools support, Client side support using Bower, Grunt & Gulp for building automatically, and as usual NuGet for .NET packages. 

ASP.NET Core

.NET Core application with Command Prompt & VS Code

Once we have installed the .NET Core Framework on our system, since it is open source, the .NET Framework can be accessed and projects can be maintained through command prompt. Just open the command prompt, and execute "dotnet". It will output the entire information of the .NET Framework.

ASP.NET Core

To create a new project using the .NET templates, use the scaffolding in VS IDE. The same scaffolding is also possible in the command prompt with the command, "dotnet new". This creates the scaffolding and restores the packages required if they do not exist.

ASP.NET Core

Then, use the scaffolding templates,

ASP.NET Core

Here, we see multiple templates. Choose one of the templates and set the path where the project needs to be added. Now, let's create a console application in one of our drives. To add a new console application, the command is entered as seen below:

ASP.NET Core

Here, a new project is created, a console application for "Hello World". Then, when you run it, you get a namespaces missing error and now navigating into the directory, you find that the bin and obj folders are missing. Thus, the error is shown below:

ASP.NET Core

Thus, restoring the packages solves the issue. The "dotnet restore"  command resolves and restores the required default packages for the console application. Then, we build the project in order to ensure the code is errorless. Use "dotnet build" and then after the build succeeds, run the project to get the output.
 
Finally, use "dotnet run". 
 
The output is shown below:

ASP.NET Core

The same can be achieved in the terminals of Linux OS as well as Mac OS. The .NET Core Framework needs to be installed on the OS which is why .NET Core is developed to make it cross platform. In upcoming articles, we will look into more details of .NET Core, such as creating web applications using .NET Core and the MVC6.