basic06
program.cs
// program.cs app.UseRouting(); app.UseLoadRequestDataMiddlerWare(); app.UseCheckUserSessionMiddleWare(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
LoadRequestDataMiddlerWare.cs
private readonly RequestDelegate _next; public LoadRequestDataMiddlerWare(RequestDelegate next) { _next = next; }1. Middleware1 λ©μλ μμμ `await _next(context)`μΌλ‘ Middleware2 λ©μλ νΈμΆ. 2. Middleware2 λ©μλ μμμ λ `await _next(context)` Middleware3 λ©μλ νΈμΆ. 3. Middleware λ©μλμμ κ³μν΄μ next Middleware λ©μλλ₯Ό νΈμΆν¨ 4. EndPoint Middleware(nextκ° μλ λ§μ§λ§ λ―Έλ€μ¨μ΄)μμλ void λλ μ΄λ€ κ°μ 리ν΄νλ©΄μ μ’ λ£. 5. μ΄μ λ©μλμμ `await _next(context)`μ λ€μ μ€ μ½λλΆν° μ΄μ΄μ κ³μ μ§ννλ€κ° void λλ μ΄λ€ κ°μ 리ν΄νλ©΄μ μ’ λ£. 6. λκΉμ§ λμμμ νλ μμν¬ λ΄λΆμμ λμνλ κ°μ²΄κ° Responseλ₯Ό 보λ
MiddlewareExtentions.cs
Last updated