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.).
Open Visual Studio and File –> New –> Project. Select ASP.Net Core Web Application (.Net Core) template.
Select Web Application as shown below. If a prompt shows up asking to create Cloud service, skip it from now by clicking on cancel.
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).
The solution can be run by clicking
And the output would be as shown below.
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”.
First lets restore the nuget packages by running “dotnet restore” command (assume this is first time run of the project).
Now we can build the solution using “dotnet build” command.
Finally we cab run the solution using “dotnet run” command.
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!!!