IApplicationBuilder
Used to configure the application middleware pipelineMap() -> IApplicationBuilder
MapWhen() -> IApplicationBuilder
Run() -> void
Use() -> IApplicationBuilder
UseMiddleware() -> IApplicationBuilder
UsePathBase() -> IApplicationBuilder
UseRouting() -> IApplicationBuilder
UseRouter(Action<IRouteBuilder> action) -> IApplicationBuilder
UseEndpointPoints() -> IApplicationBuilder
View Output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** Value Objects ** | |
/user/123/posts?page=2&f=&q=test%20with%20spaces | |
/user/123/posts/?page=2&f=&q=test%20with%20spaces | |
user/123/posts?page=2 | |
user/123/entity%20with%20spaces?page=2 | |
/user/123?page=2 | |
/user/123/posts?page=2 | |
** Ordinal ** | |
/user/123/posts?page=2 |
View Index.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page | |
@model IndexModel | |
@{ | |
ViewData["Title"] = "Home page"; | |
<div class="card"> | |
<div class="card-body"> | |
@await Model.GetInspirationalQuote() | |
</div> | |
<div class="card-footer"> |
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Buffers; | |
using System.Buffers.Text; | |
using System.Diagnostics; | |
using System.IO.Compression; | |
using System.Security.Cryptography; | |
using System.Text; | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
BenchmarkRunner.Run<Benchmarks>(); |
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Authentication; | |
using Microsoft.Extensions.Options; | |
var builder = WebApplication.CreateBuilder(args); | |
// Add services to the container. | |
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | |
builder.Services.AddEndpointsApiExplorer(); | |
builder.Services.AddSwaggerGen(); |
View GetProjectVersion.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Put this in sub-directory of the project named 'assets' --> | |
<Project> | |
<Target Name="_ExtractVersionMetadata"> | |
<WriteLinesToFile File="$(_ProjectVersionMetadataFile)" Lines="$(Version)" /> | |
</Target> | |
</Project> |
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Buffers.Text; | |
using System.Text; | |
using System.Text.Json; | |
using System.Text.Json.Serialization; | |
using Microsoft.AspNetCore.Authentication; | |
using Microsoft.AspNetCore.Authentication.JwtBearer; | |
using Microsoft.AspNetCore.Authorization; | |
using Microsoft.Extensions.Options; | |
using Microsoft.OpenApi.Models; | |
using Swashbuckle.AspNetCore.SwaggerGen; |
View EndpointRoutingBuilders.md
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.MapGroup("/apis", apis => | |
{ | |
apis.UseExceptionHandler("/error"); | |
var problemJsonMediaType = new MediaTypeHeaderValue("application/problem+json"); | |
apis.MapGet("/error", (HttpContext context) => | |
{ | |
// Get exception details | |
var error = context.Features.Get<IExceptionHandlerFeature>()?.Error; | |
var badRequestEx = error as BadHttpRequestException; |
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Now | |
app.MapGet("/todos/{id}", async (int id, TodoDb db) => | |
await db.Todos.FindAsync(id) | |
is Todo todo | |
? Results.Ok(todo) | |
: Results.NotFound()) | |
.WithName("GetTodoById") | |
.Produces<Todo>(StatusCodes.Status200OK) | |
.Produces(StatusCodes.Status404NotFound); |
NewerOlder