The Minimal ASPNET Core 1.1 App

Date Published: 12 December 2016

The Minimal ASPNET Core 1.1 App

In a previous article, I described how to create the minimal ASP.NET Core 1.0 app. That is, what’s the smallest amount of code you could write to produce an ASP.NET Core application?

In this article, I’ll demonstrate how to do the same for ASP.NET Core 1.1. The main difference is in the project file, which has moved from project.json to a .csproj format. If you’re just getting started with .NET Core, install the SDK and tools, first. You can use Visual Studio Code (or any text editor) for these steps. Once you have the SDK and command line tools installed, open a command prompt in an empty folder. Run the following commands:

dotnet new

This will create two files, Program.cs and [foldername].csproj. Next, you need to add a package reference to the project file, to add the built-in ASP.NET Core web server, Kestrel, to the project. Open the .csproj file with Visual Studio Code (or another text editor). Add this code block under the PackageReference element that includes the “Microsoft.NETCore.App” package:

<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel"> <Version>1.1</Version> </PackageReference>

The complete project file after this change should look like this:


Exe netcoreapp1.0 1.0.1 1.1 1.0.0-alpha-20161104-2 All `

Now modify Program.cs to configure a web host, tell it to use Kestrel, and set up a single response to all requests (to return “Hi”):

using Microsoft.AspNetCore.Hosting;
`using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http;

class Program { static void Main(string[] args) { new WebHostBuilder() .UseKestrel() .Configure(a => a.Run(c => c.Response.WriteAsync("Hi!"))) .Build() .Run(); } }`

Return to your command prompt, and run these commands:

dotnet restore dotnet run

You should see output like this:

minimal aspnetcore11 program

Open a browser and navigate to localhost:5900. You should see a simple response of “Hi”.

Steve Smith

About Ardalis

Software Architect



Copyright © 2021