📜  通用异常处理程序 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:53.907000             🧑  作者: Mango

代码示例1
app.UseExceptionHandler(appBuilder =>
           {
               appBuilder.Run(async context =>
               {
                   context.Response.Headers.Add("Access-Control-Allow-Origin", "*");   // I needed to add this otherwise in Angular I Would get "Response with status: 0 for URL"
                   context.Response.StatusCode = 500;
                   await context.Response.WriteAsync("Internal Server Error");
               });
           });