45 (and counting) ASP.NET Core Samples
I came across this repo by accident and as soon as I saw it I knew I had today's post. I don't know about you, but I learn code by looking at code. Today's project is 45 and count cool ASP.NET code samples, from Hello World and up...
45 samples for aspnetcore fundamentals (updated daily)
Some of the samples you see here involve mixed projects (net451) that will run only in Windows. For many .NET developers, full framework is the reality for forseeable future. We are not going to port multi-year production systems to run on Linux. We want to improve the creaky .NET MVC 2.0 that we have lying around and bring it up to speed to aspnetcore MVC.
All these projects require the following dependencies
"Microsoft.AspNetCore.Hosting" : "1.0.0-*"
This dependency pulls its own dependencies which you can check at project.lock.json.
This allows us to not explicitly specify some dependencies ourselves.
If a sample require additional dependencies, I will list them.
I highly recommend using Visual Studio Code to play around with these samples but it is not required.
To run these samples, simply open your command line console, go to each folder and execute
dotnet restoreand then continue with
dotnet watch run.
Setup your most basic web app and enable the change+refresh development experience.
We are using
IApplicationBuilder Run, an extension method for adding terminal middleware.
This project contains all the available services available in Startup class constructor,
We take dependency on
"Microsoft.AspNetCore.Routing" : "1.0.0-*"to enable routing facilities in your aspnetcore apps. There are several samples to illuminate this powerful library. ...
We will explore all aspect of middleware building in this section. There is no extra dependency taken other than
dotnet watch. ...
Features are collection of objects you can obtain from the framework at runtime that serve different purposes.
- Dependency Injection
aspnetcore lives and die by DI. It relies on
Microsoft.Extensions.DependencyInjectionlibrary. There is no need to put this dependency in your
project.jsonexplicitly because aspnetcore already has this package as its own dependency.
- In Memory Caching (a.k.a local cache)
These samples depends on
Microsoft.Extensions.Caching.Memorylibrary. Please add this dependency to your
This section is all about configuration, from memory configuration to INI, JSON and XML. ...
- Localization and Globalization
This section is all about languages, culture, etc ...
Serve static files
Simply serve static files (html, css, images, etc).
This additional dependency is required to enable the functionality
There are two static files being serve in this project, index.html and hello.css. They are stored under
wwwrootfolder, which is the default folder location for this library.
To access them you have to refer them directly e.g.
Serve markdown file as html file. You will see how you can create useful app using a few basic facilities in aspnetcore.
"CommonMark.Net" : "0.13.4"as dependency.