Any useful c# practices which I found
- Prepare Project
- ASP.NET Core
-
- Authentication
-
-
- Bearer
-
using Bla.WebApi.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.ConfigureServices(/*dependencies*/);
// ...
app.ConfigureApp(/*dependencies*/);
// ...
public static class Extensions
{
public static IServiceCollection ConfigureServices(
this IServiceCollection services
/*dependencies*/
)
{
// services.AddAnyService();
return services;
}
public static WebApplication ConfigureApp(
this WebApplication app
/*dependencies*/
)
{
// app.UseAnyMiddleware(); or else
return app;
}
// Private methods
}
You can use ConfigureServices
and ConfigureApp
methods in Startup.cs
directly.
Or you can split logic in other layers by Dependency Injection
.