AspNet6InDepth
1.0.0
ASP.NET 6 overview
ASP.NET 6 Fundamentals
Program.cs fileIMiddleware interfaceRequestDelegate objectapp.Use, app.Map, app.MapWhen, app.UseWhen and app.Runapp.UseStaticFiles();app.UseCors();ProblemDetails responseappsettings.{environment}.json and the IConfiguration interfaceIOptions<T> interfaceIOptionsSnapshot<T> or IOptionsMonitor<T> interfaceHttpContext, HttpContext.Request and HttpContext.ResponseRoute attributeHttpGetAttribute, HttpPostAttribute, HttpPutAttribute, HttpPatchAttribute and HttpDeleteAttributeFromQuery : Gets values from the query stringFromRoute : Gets values from route dataFromForm : Gets values from posted form fieldsFromBody : Gets values from the request bodyFromHeader : Gets values from HTTP headersIActionResult<T> or ActionResult<T>Accept header
Accept header is set to application/xmlAccept header is set to application/jsonHTTP Patch type requestsCompare : Validate if two properties in a model match.EmailAddress : Validate if a property has an email format.Phone : Validate if a property has a telephone number format.Range : Validate if a property value falls within a specified range.RegularExpression : Validate if a property value matches a specified regular expression.Required : Validate if a field isn't null.StringLength : Validate if a string property value doesn't exceed a specified length limit.Url : Validate if a property has a URL format.IHttpClientFactory.CreateClient();gzip algorithmAspNetCoreRateLimit nuget package with memory provider.AspNetCoreRateLimit and AspNetCoreRateLimit.Redis nuget package with Azure Cache for Redis provider.ILogger<T> extension methods
logger.LogTrace log trace level messageslogger.LogDebug log debug level messageslogger.LogInformation log information level messageslogger.Warning log warning level messageslogger.Error log error level messageslogger.Critical log critical level messagesAzure AppInsights SDKIHostedService interfaceBackgroundService classSwashbuckle.AspNetCore nuget for adding Swagger OpenAPI supportswagger.json from root levelData Access in ASP.NET 6 API Application
Data Access using Micro ORM Dapper and PostgreSQL
/api/Persons?page=1&limit=10/api/Persons?searchAfter=4499b79a-c710-45e4-ba87-083d22c4d6ad_2023-04-17T12:00:25&limit=10/api/Persons/b1333cad-9d7c-4a64-8823-db8c9aa55646/api/Persons/api/Persons/b1333cad-9d7c-4a64-8823-db8c9aa55646/api/Persons/b1333cad-9d7c-4a64-8823-db8c9aa55646Data Access using EF Core 6 ORM and PostgreSQL
DbSet<T> to model tables in databaseDbContextidempotent option/api/Employees?page=1&limit=10/api/Employees?searchAfter=4499b79a-c710-45e4-ba87-083d22c4d6ad_2023-04-17T12:00:25&limit=10/api/Employees/b1333cad-9d7c-4a64-8823-db8c9aa55646/api/Employees/api/Employees/b1333cad-9d7c-4a64-8823-db8c9aa55646/api/Employees/b1333cad-9d7c-4a64-8823-db8c9aa55646Response Caching in ASP.NET 6 API Application
IMemoryCacheStackExchange.RedisSecurity in ASP.NET 6 API Application
Add Authentication
Claim, ClaimsIdentity and ClaimsPrincipalBCrypt.Net-Next nugetSystem.IdentityModel.Tokens.Jwt/api/Account/Register to register the user/api/Account/Login to login the user and generate the initial set of access token and refresh token/api/Account/Token to refresh the access token using the refresh token sent/api/Account/Revoke to revoke the refresh tokenAdd Authorization
IAuthorizationRequirement interfaceHandleRequirementAsync to make custom policy requirementProgram.csCase Study: Add JWT Authentication and Role Authorization using Auth0
Handling file uploads and file downloads
wwwroot folder.xlsx file to responseTesting
Unit Testing
xUnit.net[Fact] and [Theory]Dispose method[InlineData][MemberData][ClassData]IClassFixtureICollectionFixtureMoqVerify() or VerifyAll()Integration Testing
WebApplicationFactory<TStartup>xUnit.netSynchronous Inter-Service communication using gRPC and HTTP2
Asynchronous Inter-Service communication using Message Queues
Hosting ASP.NET 6 API application