Getting Started with ASP.Net Core Application

In this short tutorial, I am going to show on how to get started with ASP.Net Core Application. ASP.Net Core is a completely new, open source and cross platform framework from Microsoft. ASP.Net Core Applications primarily work with two different frameworks – .Net Core and .Net Framework. .Net Core is used to support multiple platforms like mac OS, Linux and Window, where as .Net framework supports only Windows.  One more advantage of ASP.Net Core Application is that it can support both the before mentioned frameworks at the same time in same project (for other .Net Core Projects, there are other frameworks like .Net Standard).

There are many other breaking changes and advantages with ASP.Net Core Applications, I will take a different tutorials to go through each and every one of them. The scope of this tutorial is to quickly build the first ASP.Net Core 1 application.

NOTE: Updated this tutorial on 2/26/2017 with MSBuild based Dotnet SDK.

Create an ASP.Net Core Application using VS 2017. I am using following version of Dotnet SDK which is based on MSBuild/CSProj (remember that previous versions of ASP.Net Core are based on Project.json/XProj.).

image

Open Visual Studio and File –> New –> Project. Select ASP.Net Core Web Application (.Net Core) template.

image

Select Web Application as shown below. If a prompt shows up asking to create Cloud service, skip it from now by clicking on cancel.

image

Following solution will be created and immediately all the references will be restored from nuget (to support modular design all the dependencies of .Net Core Project will be derived from nuget).

image

The solution can be run by clicking

 image

And the output would be as shown below.

image

 

The same solution can be executed through Dotnet CLI commands. Open command prompt and go to the folder location where project as been created. To make sure Dotnet CLI has been installed, check for its version as shown below using “dotnet –version”.

image

First lets restore the nuget packages by running “dotnet restore” command (assume this is first time run of the project).

image

Now we can build the solution using “dotnet build” command.

image

Finally we cab run the solution using “dotnet run” command.

image

We can browse to the URL (http://localhost:5000 ) at which app was hosted.

That’s it for now. We will see more .Net Core concepts in upcoming tutorials. Happy Coding and Stay tuned!!!

You may also like...