แก้บั้ก Global Exception Middleware
This commit is contained in:
parent
b99d7e759b
commit
01c55f296d
3 changed files with 6 additions and 3 deletions
|
|
@ -31,18 +31,20 @@ namespace BMA.EHR.Domain.Middlewares
|
|||
await _next(context);
|
||||
|
||||
var response = context.Response;
|
||||
response.ContentType = "application/json";
|
||||
|
||||
|
||||
var responseModel = new ResponseObject();
|
||||
responseModel.Status = response.StatusCode;
|
||||
|
||||
if (responseModel.Status == (int)HttpStatusCode.Unauthorized)
|
||||
{
|
||||
response.ContentType = "application/json";
|
||||
responseModel.Message = GlobalMessages.NotAuthorized;
|
||||
await response.WriteAsJsonAsync(responseModel);
|
||||
}
|
||||
if (responseModel.Status == (int)HttpStatusCode.Forbidden)
|
||||
{
|
||||
response.ContentType = "application/json";
|
||||
responseModel.Message = GlobalMessages.ForbiddenAccess;
|
||||
await response.WriteAsJsonAsync(responseModel);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue