Oracle 儲存過程批量刪除按日建立分割槽表的表分割槽
阿新 • • 發佈:2020-11-04
核心物件
- IApplicationBuilder
- RequestDelegate
程式碼演示
app.Use(async (context, next) => { await context.Response.WriteAsync("hello Word"); });
指定路徑
程式碼演示
app.MapWhen(context => { return context.Request.Query.Keys.Contains("id"); }, builder => { builder.Use(async (context, next) => { await context.Response.WriteAsync("hello Word"); }); });
自定義中介軟體
中介軟體程式碼
public class MyMiddleware { RequestDelegate _next;public MyMiddleware(RequestDelegate next) { _next = next; } public async Task InvokeAsync(HttpContext context) { Console.WriteLine("===========執行前邏輯=========="); await _next(context); Console.WriteLine("===========執行後邏輯=========="); } }
擴充套件方法
public static class MyBuilderExtensions { public static IApplicationBuilder UserMyMiddleware(this IApplicationBuilder app) { return app.UseMiddleware<MyMiddleware>(); } }
Startup類註冊中介軟體
app.UserMyMiddleware();
異常處理中介軟體
程式碼演示
app.UseExceptionHandler(errorApp => { errorApp.Run(async context => { IExceptionHandlerPathFeature exceptionHandlerPathFeature = context.Features.Get<IExceptionHandlerPathFeature>(); context.Response.ContentType = "application/json;charset=utf-8;"; context.Response.StatusCode = StatusCodes.Status200OK; await context.Response.WriteAsync(JsonConvert.SerializeObject(exceptionHandlerPathFeature)); }); });