• Stars
    star
    654
  • Rank 68,870 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created over 3 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A place I'm trying out the new ASP.NET Core minimal APIs features.

Minimal API Playground

A place I'm trying out the new ASP.NET Core minimal APIs for hosting and HTTP APIs.

Dependencies

Code in this repo depends on the very latest bits. If you want to try it out, grab the latest .NET 7 SDK installer.

MinimalValidation

First-class support for validation as part of the new minimal APIs is not currently planned to be implemented. However it's fairly straightforward to wire up the validation features found in System.ComponentModel.Validation through the use of a helper library (like the example this repo uses), or by using an existing validation library like FluentValidation.

Projects

Todo.Dapper

This project implements a simple Todos API including OpenAPI (Swagger) documentation and UI, and uses the Dapper library to persist data to a SQLite database.

There are some simple tests for this project in the tests/Todo.Dapper.Tests project.

Todo.EFCore

This project implements a simple Todos API including OpenAPI (Swagger) documentation and UI, and uses using Entity Framework Core to perist data to a SQLite database.

MinimalApiPlayground

This project contains numerous examples of ways to use and extend the new minimal APIs in ASP.NET Core 6/7 to build HTTP APIs.

While the Program.cs file in the project root is where the APIs are registered and implemented, much of the custom code is in the Properties directory. I keep it there as almost all .NET projects have a Properties directory and I wanted to avoid additional directories in the project to avoid any implication that additional special directories are required. Ultimately it's just code and be placed anywhere in the project.

The project includes examples of the following and more:

  • Returning strings and objects directly from APIs
  • Implementing APIs using inline anonymous lambdas, local functions, or methods
  • Using the in-framework Results and TypedResults helper classes to return common results
  • Returning custom IResult objects
  • Inferred parameter binding from route data, query-string, request body as JSON, DI container services, and HTTP request objects
  • Parameter optionality inference from parameters nullability
  • Custom parameter binding from query-string or route data values via TryParse
  • Custom async parameter binding from the request via BindAsync
  • An example extensible parameter binding object model IParameterBinder that enables creating binders for types you don't own
  • Using MVC ModelBinder implementations via a custom binding shim
  • Handling file uploads via a custom BindAsync implementation
  • Handling media types other than JSON by working directly against the incoming HttpRequest and returning a custom IResult implementation
  • Handling input validation using the MiniValidation library
  • Configuring error handling using UseExceptionHandler
  • Mutating responses from APIs via custom middleware
  • Using endpoint metadata to customize OpenAPI (Swagger) API descriptions
  • An experimental middleware for handling cross-site request forgery concerns using the framework's included IAntiforgery functionality
  • Running the framework's default inferred parameter binding logic on-demand
  • A custom set of extensions to gather metadata from the return types and parameter types in endpoint route handlers and use it to auto-describe complex route handlers to ApiExplorer without the need to manually annotate the route handlers with attributes or chained metadata method calls

More Repositories

1

MiniValidation

A minimalist validation library for .NET built atop the existing features in `System.ComponentModel.DataAnnotations` namespace
C#
339
star
2

TagHelperPack

A set of useful, and possibly opinionated, Tag Helpers for ASP.NET Core
C#
338
star
3

RazorSlices

Lightweight Razor-based templates for ASP.NET Core without MVC, Razor Pages, or Blazor.
HTML
315
star
4

MinimalApis.Extensions

A set of extensions and helpers for working with ASP.NET Core Minimal APIs.
C#
296
star
5

BlazorIdentity

An exploration of recreating the ASP.NET Core Identity UI functionality in Blazor components.
C#
135
star
6

aspnet5-workshop

ASP.NET 5 workshop
106
star
7

TagHelperStarterWeb

ASP.NET 5 Starter Web project template converted to use Tag Helpers
JavaScript
80
star
8

RazorPagesSample

Examples of various ways to build simple CRUD pages using ASP.NET Core Razor Pages (coming in ASP.NET Core 2.0).
C#
77
star
9

aspnetcore-workshop

ASP.NET Core
C#
71
star
10

PiDnx

A sample DNX app for running on Windows 10 IoT Core on Raspberry Pi 2
C#
61
star
11

NDCLondon2013

Demos from my talks at NDC London 2013
JavaScript
55
star
12

AspNetCoreDevJwts

Experimenting with development environment scenarios for JWT authentication.
C#
42
star
13

Nanorm

A tiny data-access helper library for ADO.NET. Linker and native AOT friendly.
C#
41
star
14

AspNetCorePathAuthorization

A middleware to enable path-based authorization in an ASP.NET Core application.
C#
38
star
15

TrimmedTodo

An app to try out trimming stuff in .NET 7
C#
34
star
16

grunt-tsng

A TypeScript pre-processor for AngularJS
JavaScript
29
star
17

MinimalRazorComponents

An exploration of allowing returning rendered Razor Components (aka Blazor Components) from ASP.NET Core Minimal API endpoints.
C#
27
star
18

SignalR-MoveShapeDemo

A simple demo app I use when giving talks on SignalR
JavaScript
21
star
19

KeyTips-jQuery-Plugin

The KeyTips plugin for jQuery (formerly the Access Key Highlighter plugin) provides various options for highlighting access keys on web forms when the user presses their browser's access key shortcut key, e.g. Alt in Internet Explorer and Safari, Shift+Alt in Firefox.
JavaScript
21
star
20

Unobtrusive-jQuery-UI

Unobtrusive wire-up of jQuery UI features using data-ui-* attributes on target elements.
JavaScript
19
star
21

AspNetCoreClientLibManagement

Examples of different techniques for management of client libraries (i.e. JS/CSS libraries/frameworks) to ASP.NET Core projects.
HTML
18
star
22

i18nStarterWeb

ASP.NET 5 Starter Web project template converted to use proposed i18n/l10n system
JavaScript
16
star
23

vNextBowerGrunt

A demonstration of an approach for integration of Bower and Grunt into an ASP.NET vNext project.
JavaScript
16
star
24

dotnetConf2014

Demos from my dotnetConf 2014 SignalR talk http://channel9.msdn.com/Events/dotnetConf/2014/SignalR
JavaScript
15
star
25

SystemWebSdk

Exploration of using new .NET SDK-style projects with ASP.NET (System.Web) projects
JavaScript
15
star
26

SignalR-2.x-demo

Demos for SignalR 2.0 and upcoming 2.x releases
JavaScript
14
star
27

BlazingPageHead

Example of Blazor components for managing page head content.
HTML
13
star
28

Ignite2022

Demos for talk at MS Ignite 2022 with David Fowler
C#
12
star
29

YouTubePlaylistCopier

A one-page ASP.NET Core site that allows for copying items from one YouTube playlist to another.
C#
11
star
30

ndcoslo2016

Demos for NDC Oslo 2016
C#
11
star
31

TrackDirty-jQuery-Plugin

The TrackDirty plugin for jQuery tracks changes to form fields. When changes are detected, the field's class name is updated so as to allow styling. A callback function can be passed which will be called when a field is marked dirty. You can also query dirty fields using the added ":dirty" pseudo class.
JavaScript
11
star
32

aspConf2012

Demo code from talks at aspConf2012
JavaScript
10
star
33

AspNetCoreVbHybrid

Example of ASP.NET Core application with logic written in Visual Basic
C#
8
star
34

WebFormsModelBindingExtensions

Sample extensions for ASP.NET Web Forms Model Binding
C#
8
star
35

RazorPagesLocalization

Sample of fixed Razor Pages localization in ASP.NET Core 2.0.0 application
C#
7
star
36

RealTimeEntityFramework

Some ideas for real-time extensions to Entity Framework
C#
7
star
37

MusicStore

JavaScript
6
star
38

SimpleMvcHack

Some hacky ideas for simplifying MVC for page-focused scenarios.
C#
6
star
39

CookieConsentUI

Example cookie consent UI for ASP.NET Core project templates, coming in ASP.NET Core 2.1
C#
6
star
40

dotnet-new2

A .NET Core CLI command to create new .NET Core projects using templates installed via NuGet packages.
C#
5
star
41

jQueryVsDocBuilder

Utility for creating jQuery vsdoc files for Visual Studio IntelliSense
JavaScript
4
star
42

GittR

Simple issue management board for GitHub projects with real-time updating using ASP.NET SignalR.
JavaScript
4
star
43

UrlRewriteToPublic

Use URL Rewrite in IIS to only serve documents from /public folder
C#
3
star
44

MoveShapeCore

Move Shape for ASP.NET Core SignalR
JavaScript
3
star
45

Northwind

Northwind packages for Entity Framework Code First and VS11 Database projects
3
star
46

UnauthorizedApis

Exploration of potential change to ASP.NET Core behavior for what happens when accessing unauthorized API endpoints.
C#
3
star
47

CustomCultureExample

Demonstrates the issue of trying to localize for custom cultures in .NET Core/.NET 5+ projects.
HTML
3
star
48

AspireStarterDb

C#
3
star
49

MusicStoreSpa

2
star
50

BlazorFormFun

Reproducing patterns, etc. with new Blazor form handling in ASP.NET Core 8
CSS
2
star
51

HeritageTemplates

It's the .NET templates the way you remember them.
C#
2
star
52

AngleBracketsSpring2013

Deoms from my presentations at AngleBrackets/DevIntersections Spring 2013
JavaScript
2
star
53

RazorPages

C#
1
star
54

RazorFlushing

Examples of preemptive flushing from ASP.NET Core Razor
C#
1
star