Introduction to the ASP.NET Runtime
ASP.NET
is an open-source server-side web application framework designed for web development to produce dynamic webpages. That’s what Wikipedia says about it anyway… I personally had no clue what it was until I recently began taking a course that was available as part of the free 6 months worth of Pluralsight I picked up from the Visual Studio Dev Essentials pack.
Three Frameworks
There are three frameworks available, each of them seamlessly integrate with one and other and provide different levels of functionality.
.NET 4.6
is the .NET we’ve always known. It was built for the windows platform so it didn’t natively function on other systems. This is where Mono came in.
Mono
is a community driven project that allows .NET code to run on OSX/Linux systems. It is still widely used and very popular.
.NET Core
is the most recent edition to the .NET family. It’s open source like Mono but supports both Windows, OSX and Linux platforms.
- CoreCLR is a subset of the .NET Framework.
Installing ASP.NET
- Start by first installing Visual Studio 2015 if you haven’t already got it on your system.
- The install process can be quite lengthy, maybe go get 5-6 cups of coffee while you wait.
-
Download and install
ASP.NET 5
from here. - You will now have access to the
DNVM
cmdlet. Running the following command will display a full list of commands you have access to.
Setting up
Running the command dnvm list
from command line will result in a list of the current versions of ASP.NET 5 you currently have installed on your system
These runtimes are stored in your user directory, and you can prove this by listing the files in .dnx\runtimes
. Run the following to show a list of installed runtimes under your home directory.
You can also run dnvm upgrade
in order to pull down the most recent versions of the ASP.NET 5 runtime. If there is a more recent runtime available it will be downloaded and set as your default runtime.
You can also manually pull down other versions using the following in order to support different architectures.
You might also want the coreclr
versions, in which case you can run the following to pull down the respective version. Do the same for the x86 version.
With a full suite of runtimes installed, you can now use the following command to switch between runtimes.
Note that the -p
makes the path persistent so you won’t need to re-run the command each time you open a new terminal
Running dnx --version
will show you the runtime currently active
Hello World
At this stage we are ready to use the runtime we just installed. In order to do this you’ll need to create two new files in a working directory with the following contents
project.json
Specifies the framework we want to use. can also contain other project based traits (you’ll see this in up-comming tutorials)
program.cs
Contains straight C#
code.
And that’s it!. You can run your Hello World using the following syntax:
Summary
As someone new to the .NET scene I was astounded by how simple it was to get started with ASP.NET and I can’t wait to get my fingers into some more difficult challenges. I would highly recommend checking out the course I wrote this for; and even follow along with me as I make my way through the several hours worth of FREE content.