1
This commit is contained in:
@@ -18,9 +18,13 @@
|
||||
}
|
||||
|
||||
private async Task HandleExceptionAsync(HttpContext context, Exception ex)
|
||||
{
|
||||
if (!context.Response.HasStarted)
|
||||
{
|
||||
context.Response.ContentType = "application/problem+json";
|
||||
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
|
||||
}
|
||||
|
||||
var title = "";
|
||||
var message = "";
|
||||
var exType = ex.GetType();
|
||||
@@ -50,6 +54,8 @@
|
||||
_logger.LogError(ex, "Exception");
|
||||
}
|
||||
|
||||
if (!context.Response.HasStarted)
|
||||
{
|
||||
var acceptHeader = context.Request.Headers["Accept"].FirstOrDefault();
|
||||
var isAjaxRequest = acceptHeader?.Contains("application/json") == true;
|
||||
if (isAjaxRequest)
|
||||
@@ -67,6 +73,7 @@
|
||||
{
|
||||
await context.Response.WriteAsync(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user