Winner's Excogitations

A chronicle of the thoughts, learning experiences, ideas and actions of a tech junkie, .NET, JS and Mobile dev, aspiring entrepreneur, devout Christian and travel enthusiast.

Getting Started With ASP.NET Core (Part 1)

7 years ago · 3 minutes read

ASP.NET Core is the new direction that Microsoft is taking their web technologies. It is still in its early stages but is showing a lot of promise. Between versions 1.0 and 1.1, the Kestrel server has shown significant speed improvements. ASP.NET Core is a significant departure from the previous generation of ASP.NET in that it was (and currently is) a community-driven and developed project whose source code can be found on GitHub. ASP.NET Core also has the advantage of being very modular, this means that it can be run on IIS Servers, or the newer, lighter Kestrel Server. Another advantage ASP.NET Core has is that it shares a single set of libraries for creating Web API and Web applications. The most important advantage is that unlike traditional ASP.NET, ASP.NET Core is fully cross-platform.

At the end of this tutorial, we’ll create a full-fledged Notes application and deploy it to Heroku, but for this part, we’ll start with a basic application which would show “Hello World” in the browser.

We would be using the ASP .NET Core yeoman generator to spin up our web application. If you don’t have the ASP .NET Core generator, you can install it via npm. The following dependencies are required:

  1. .NET Core SDK which can be gotten from here 

  2. Node JS which can be gotten from here

  3. Yeoman which can be installed by running

    npm install -g yo
    
  4. Bower which can be installed by running

    $ npm install -g bower
    
  5. ASP .NET yeoman generator by running

    $ npm install -g generator-aspnet
    

Once you’re all set, run the following command;

$ yo aspnet

You should see the following screen;

bolorundurowb_com/production/article/zaanse3yobxhak08gjdl

Select the “Empty Web Application” option using the up and down arrow keys and accept with the Enter key.

Set your app name, for this tutorial, we’ll use cookieauth.

bolorundurowb_com/production/article/tgarpyfntheu2qwzvbaj

After that, a set of files would be created in the folder cookieauth

Next change directory to the cookieauth folder using:

$ cd cookieauth

Run the commands

$ dotnet restore

To get all required libraries from Nuget

$ dotnet build

To compile the existing code to an executable

bolorundurowb_com/production/article/bkx7sr7nzry6m18vxgph

$ dotnet run

This would run the empty app on the default port (5000) and can be accessed via the URL http://localhost:5000

bolorundurowb_com/production/article/awedmxwbxk7xx19awajl

If you visit HTTP://localhost:5000 in your browser, you should see

bolorundurowb_com/production/article/bfvplsa3ykdcp9sjaspa

That would be it, for this. Check out the next tutorial in this series.

Cheers

Share on:
[HOW TO] Deploy your ASP.NET Core 1.x app to Heroku
A how to on deploying an ASP.NET Core 1.x app to Heroku
GIT - For The Absolute Beginner (Part 2)
Second in a series on the common git commands to make the version control processes a bit easier to handle
Winner-Timothy Bolorunduro
Winner-Timothy Bolorunduro is a senior .NET developer with over 6 years experience helping organizations and individuals build compelling, stable and scalable web applications. Having spent the last three years in a fast-paced startup environment working remotely, he understands what goes into being part of a team that produces value for clients.

Comments