Back to Practical Aspnetcore

Minimal API (39)

projects/minimal-api/README.md

latest6.4 KB
Original Source

Minimal API (39)

  • Hello World

    This is Hello World ASP.NET Core 6 app using the new WebApplication instead of IHostBuilder.

Minimal Routing (9)

In these examples we are using the familiar Host.CreateDefaultBuilder(args) host configuration style to emphasis that the new Minimal Routing feature works in both existing style and also in the new minimal hosting API.

Route Constraints (12)

Parameter Binding (10)

Antiforgery

Endpoint Filter

  • Endpoint Filter - 1

    This sample shows how to apply an Endpoint filter to your minimal API.

  • Endpoint Filter - 2

    This sample shows how to apply multiple Endpoint filters to your minimal APIs.

  • Endpoint Filter - 3

    This examples shows the sequence of code execution before RouteHandlerFilterDelegate and after RouteHandlerFilterDelegate in multiple endpoint filters.

  • Endpoint Filter - 4

    Use IStatusCodeHttpResult to detect return result in filter.

Route Group

  • Route Group - 1

    MapGroup() extension methods allow grouping of endpoints with a common prefix. It also allow group metadata to be attached to the group.

  • Route Group - 2

    Use .WithTags(), .WithDescription(), .WithSummary() to enrich OpenAPI information for all the endpoints in the group. Uses .NET 10 built-in OpenAPI.

  • Route Group - 3

    Use .ExcludeFromDescription to exclude endpoints from OpenAPI description. Uses .NET 10 built-in OpenAPI.

Minimal API Improvements

  • Minimal API Form Model Binding

    This sample demonstrates the ability to use [FromForm] binding in Minimal API.

  • Typed Results - 1

    Microsoft.AspNetCore.Http.TypedResults static class is the “typed” equivalent of the existing Microsoft.AspNetCore.Http.Results class.

  • WithOpenApi - 1

    This sample demonstrates .NET 10 built-in OpenAPI support using XML comments and AddOpenApi().

  • Results<> Union Type

    Results<TResult1, TResult2, TResultN> provides better description of the result of the operation. Uses .NET 10 built-in OpenAPI.

  • IFormFile

    This sample demonstrates the usage of IFormFile to upload a file in Minimal API.

  • IFormFileCollection

    This sample demonstrates the usage of IFormFileCollection to upload multiple files in Minimal API.

dotnet8