Skip to main content

Csharp Api Course

DRAFT

Middleware is defined in the Program.cs file. eg

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

Nullability

  • If you enable nullability, also add this to your csproj
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>

My mental model of this right now is similar to strict: true in typescript projects.

Results class

Use this for api responses.

  • Results.Ok(employees)
  • Results.NotFound() etc.

Parameter binding

This one was magic for a bit

Quick find

Search the garden