Skip to content

AspNetCore

Mathieu Mack edited this page Jul 17, 2024 · 2 revisions

Welcome to the MDev.Dotnet.AspNetCore wiki!

This package let you to configure standard services on a .net web application :

  • Application configuration
  • Controllers
  • Support for synchronous IO operations
  • Routing
  • API Versioning.

Here are the details about theses configuration.

Functions

RegisterConfiguration

This extension let you to load Configuration from 3 data sources:

  • File : appsettings.json
  • File : appsettings..json. This file is optional and will not failed if not found.
  • Environment variables

On your program.cs file for your web application, you just have to call this extension :

builder.RegisterConfiguration();
        

RegisterControllers

This extension let you to configure :

  • Controllers endpoints

A default behaviour that log with warning level all Bad model state (HTTP ERROR 400) with details of invalid fields or values.

  • Synchronous IO

This can be usefull in some scenarios where you need to read HTTP Body content.

  • Default routing
  • Versioning API

Usefull to support natively attribut for version in your controllers :

[ApiVersion("1")]
[Route("api/v{version:apiVersion}/me")]  
public class MyController : ControllerBase
{

} 

On your program.cs file for your web application, you just have to call this extension :

builder.RegisterControllers<Program>();
        

Clone this wiki locally