Skip to content

Practical samples of ASP.NET Core 2.1, 2.2, 3.1, 5.0 and 6.0 Preview 7 projects you can use. Readme contains explanations on all projects.

License

Notifications You must be signed in to change notification settings

rendaardy/practical-aspnetcore

Repository files navigation

Samples for ASP.NET Core 3.1

There is a section containing .NET 5 Preview 2 specific samples here.

Additional Sections

Continue to scroll down to find materials for absolute beginners to ASP.NET Core.

Sections
Blazor Client Side (Web Assembly) Middleware
Blazor Server Side MVC
Caching Razor Pages
Configurations Orchard Core
Dependency Injection Request
Diagnostics Response
Endpoint Routing Static Files and File Provider
Features System.Text.Json
Health Check Startup
IHttpClientFactory URL Redirect/Rewrite
IHostedService Syndications
Generic Hosting Uri Helper
gRPC Web Sockets
Logging Web Utilities

How to run these samples

To run these samples, simply open your command line console, go to each folder and execute dotnet watch run.

Foundation ASP.NET Core 3.1 Samples

Basic

  • Hello World

    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.

  • Hello World - 2

    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.

  • IWebHostConfiguration

    This sample demonstrates the usage of IWebHostEnvironment from Configure method.

  • IHostEnvironment

    This sample shows how to access IHostEnvironment from ConfigureServices.

  • IConfiguration

    This sample demonstrates the usage of IConfiguration from `Configure' method.

Misc

  • Application Environment

    This sample shows how to obtain application environment information (target framework, etc).

  • Show Connection info

    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.

  • Password Hasher server

    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.

  • Version info

    Show various version info of the framework your system is running on.

  • IApplicationLifetime

    Responds to application startup and shutdown.

    We are using IApplicationLifetime that trigger events during application startup and shutdown.

Server-Sent Events

  • Forever Server

    This server will send a 'hello world' greeting forever.

Markdown

Utils

  • Status Codes

    Here we contrast between the usage of Microsoft.AspNetCore.Http.StatusCodes and System.Net.HttpStatusCode.

  • MediaTypeNames

    This class provides convenient constants for some common MIME types. It's not extensive by any means however MediaTypeNames.Text.Html and MediaTypeNames.Application.Json come handy.

  • MediaTypeNames - 2

    Using FileExtensionContentTypeProvider to obtain the correct MIME type of a filename extension.

Device Detection

The samples in this section rely on Wangkanai.Detection library.

  • Device Detection

    This is the most basic device detection. You will be able to detect whether the client is a desktop or a mobile client.

Image Sharp

All these samples require SixLabors.ImageSharp.Web middleware package. This middleware is an excelent tool to process your day to day image processing need.

  • Image-Sharp

    This example shows how to enable image resizing functionality to your site. It's super easy and the middleware takes care of caching, etc.

Misc

About

Practical samples of ASP.NET Core 2.1, 2.2, 3.1, 5.0 and 6.0 Preview 7 projects you can use. Readme contains explanations on all projects.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 80.8%
  • HTML 15.7%
  • Batchfile 3.5%