Black Lives Matter. Support National Bail Fund Network.
The goal of this project is to enable .NET programmers to learn the new ASP.NET Core stack from the ground up directly from code. There is so much power in the underlying ASP.NET Core stack. Don't miss them!
I highly recommend using Visual Studio Code to play around with these samples but it is not required. You can use Visual Studio 2019 as well.
Note: If you encounter problem with downloading packages or Nuget, try the following command nuget.exe locals -clear all
.
Note There is a section containing .NET 5 Preview 7 specific samples here (29). For samples for older version of ASP.NET Core (e.g 2.1), you can find them here.
If you are studying ASP.NET Core, I am lurking on this Gitter Channel. Otherwise just create a new issue and I will try to answer the best I can.
Hi Nuget visitors, if you have problem finding the sample you are looking for, please use the github search functionality or otherwise file a case. I will be happy to point you to the right direction.
Section | |||
---|---|---|---|
Blazor Client Side (Web Assembly) (Components, Data Binding) | (18) | Middleware | (13) |
Blazor Server Side (Localization) | (15) | MVC (Localization, Routing, Razor Class Library, Tag Helpers, View Component, etc) | (46) |
Caching | (5) | Razor Pages | (9) |
Configurations | (7) | Orchard Core | (4) |
Dependency Injection | (2) | Request (Form, Cookies, Query String, Headers) | (14) |
Diagnostics | (6) | Response | (4) |
Endpoint Routing | (31) | Static Files and File Provider | (8) |
Features | (10) | System.Text.Json | (10) |
Health Check | (6) | Startup | (12) |
IHttpClientFactory | (4) | URL Redirect/Rewrite | (6) |
IHostedService | (1) | Syndications | (3) |
Generic Hosting | (9) | Uri Helper | (5) |
gRPC (including grpc-Web) | (12) | Web Sockets | (5) |
Logging | (2) | Web Utilities | (3) |
Localization and Globalization | (6) | For Data Access samples, go to the excellent ORM Cookbook. | |
Single File Application - C# 9, ASP.NET Core 5 | (1) | ||
125 | 142 |
To run these samples, simply open your command line console, go to each folder and execute dotnet watch run
.
-
This is the simplest ASP.NET Core application you can create. An ASP.NET Core application includes a super fast web server called Kestrel. In a few lines of code we set up the web server and a simple app.
In this sample we use a
Startup
class to configure your application. This is the canonical way of doing thing. -
This is the equivalent of the previous Hello World sample except that in this case we don't use a
Startup
class. This way of configuring things is not common. -
This sample demonstrates the usage of
IWebHostEnvironment
fromConfigure
method. -
This sample shows how to access
IHostEnvironment
fromConfigureServices
. -
This sample demonstrates the usage of
IConfiguration
from `Configure' method.
-
This sample shows how to obtain application environment information (target framework, etc).
-
Enumerate the connection information of a HTTP request.
-
Keeping track of anonymous users
Keep track of anonymous user in your ASP.NET Core (useful in scenario such as keeping track of shopping cart) using
ReturnTrue.AspNetCore.Identity.Anonymous
library. -
Give it a string and it will generate a secure hash for you, e.g.
localhost:5000?password=mypassword
. -
Integrate Newtonsoft.Json back
ASP.NET Core has a new built in JSON Serializer/Deserializer. This sample shows how to integrate Newtonsoft.Json back to your project.
-
Show various version info of the framework your system is running on.
-
Responds to application startup and shutdown.
We are using
IApplicationLifetime
that trigger events during application startup and shutdown. -
This project shows a simple integration between
System.CommandLine
, a command line parsing library with ASP.WNET Core app.
-
This server will send a 'hello world' greeting forever.
-
Serve markdown file as html file. You will see how you can create useful app using a few basic facilities in aspnetcore.
We take
"Markdig"
as dependency. -
Markdown server - implemented as middleware component
Serve markdown file as html file. It has the same exact functionality as Markdown server but implemented using middleware component.
We take
"Markdig"
as dependency.
-
Here we contrast between the usage of
Microsoft.AspNetCore.Http.StatusCodes
andSystem.Net.HttpStatusCode
. -
This class provides convenient constants for some common MIME types. It's not extensive by any means however
MediaTypeNames.Text.Html
andMediaTypeNames.Application.Json
come handy. -
Using
FileExtensionContentTypeProvider
to obtain the correct MIME type of a filename extension.
The samples in this section rely on Wangkanai.Detection library.
-
This is the most basic device detection. You will be able to detect whether the client is a desktop or a mobile client.
All these samples require SixLabors.ImageSharp.Web
middleware package. This middleware is an excelent tool to process your day to day image processing need.
-
This example shows how to enable image resizing functionality to your site. It's super easy and the middleware takes care of caching, etc.