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