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.Run
app.UseStaticFiles();
app.UseCors();
ProblemDetails
responseappsettings.{environment}.json
and the IConfiguration
interfaceIOptions
interfaceIOptionsSnapshot
or IOptionsMonitor
interfaceHttpContext
, HttpContext.Request
and HttpContext.Response
Route
attributeHttpGetAttribute
, HttpPostAttribute
, HttpPutAttribute
, HttpPatchAttribute
and HttpDeleteAttribute
FromQuery
: 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
or ActionResult
Accept
header
Accept
header is set to application/xml
Accept
header is set to application/json
HTTP 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
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-db8c9aa55646
Data Access using EF Core 6 ORM and PostgreSQL
DbSet
to model tables in databaseDbContext
idempotent
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-db8c9aa55646
Response Caching in ASP.NET 6 API Application
IMemoryCache
StackExchange.Redis
Security in ASP.NET 6 API Application
Add Authentication
Claim
, ClaimsIdentity
and ClaimsPrincipal
BCrypt.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.cs
Case 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]
IClassFixture
ICollectionFixture
Moq
Verify()
or VerifyAll()
Integration Testing
WebApplicationFactory
xUnit.net
Synchronous Inter-Service communication using gRPC and HTTP2
Asynchronous Inter-Service communication using Message Queues
Hosting ASP.NET 6 API application