Skip to content

.NET Competence Center: WebApi course

Notifications You must be signed in to change notification settings

itenium-be/ASP.NET-WebApi

Repository files navigation

ASP.NET WebApi

Prep

  • Update to last version of Visual Studio 2022
  • Install Docker for Windows
  • Install .NET 7 SDK
  • Node v16+ (?)
  • docker pull postgres:15-alpine

postgres

Login: postgres / admin
Port: 5433
Database: socks

cd WebApi/docker-compose
docker compose up -d

WebApi

/WebApi: Swagger @ localhost:5001/swagger

Template: FullStackHero

Get a Token

Swagger

Tokens -> POST /api/tokens
Tenant: root

{
    "email":"admin@root.com",
    "password":"123Pa$$word!"
}

Postman

See postman for a postman collection.
Or go with an open-source & free alternative that looks exactly the same:

In Visual Studio Code:

cURL

CURL command for getting a token:

curl -X POST \
  'https://localhost:5001/api/tokens' \
  --header 'Accept: */*' \
  --header 'tenant: root' \
  --header 'Accept-Language: en-US' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "email": "admin@root.com",
  "password": "123Pa$$word!"
}'

Features

  • Multi Tenancy Support with Finbuckle
  • EF Repository Abstraction with Ardalis.Specification
  • Serilog
  • OpenAPI & Swagger
  • API Versioning
  • Fluent Validations
  • Response Caching - Distributed Caching + REDIS

REST

See REST-JWT.pptx for some general REST infos. Or see our specific REST-JWT-Postman-DevTools session.

Topics

  • Filters / custom middleware / global error handling (ActionFilterAttribute)
  • Minimal APIs
  • Versioning: Create a /v2 where we renamed products -> socks (or just uri-rewriting?)
  • Configuration json (secrets.json)
  • JSON Serialization (enums) / Zipping
  • Caching (Redis)
  • Polly (Retries)
  • Validation (Attributes and/or FluentValidation)
  • Return Http Codes
  • Working with files (upload/download)
  • Logging?

About

.NET Competence Center: WebApi course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages