暂时解决了,谢谢.
处理时把 API目录排除了.就正常了,但不知会不会影响性能.
坐等枫大大更新
app.UseWhen(
context => !context.Request.Path.Value.StartsWith("/api", StringComparison.OrdinalIgnoreCase),
builder =>
{
//全局异常
builder.UseExceptionHandler("/Error");
//页面异常
builder.UseStatusCodePagesWithReExecute("/Error/{0}");
builder.UseHsts();
}
);