I have two application one is API and one is UI, in api some methods or permission based return as per below code
if (!await _permissionMasterServcie.Authorize(StandardPermissionProvider.Category, PermissionType.View).ConfigureAwait(false)) { return AccessDenied(); }then this consume in UI .net core application. In this application some method is call by jQuery or Kendoui grid, some MVC so when UI .net core application consume API its got status code "401 Unauthorized" so can we redirect every request in UI application to access denied page when status code received "401 Unauthorized". By any attribute or any configuration in startup file. I didn't get how to do that.
UI .net core application consuming api
public virtual async Task<IRestResponse> PostAsync(string request, string endPoint, string action, string token) { string url = endPoint + action; _restClient.BaseUrl = new Uri(url); _restRequest.Method = Method.POST; _restRequest.Timeout = 900000; _restRequest.Parameters.Clear(); _restRequest.AddHeader("Authorization", token); _restRequest.AddParameter("application/json", request, ParameterType.RequestBody); IRestResponse response = await _restClient.ExecuteAsync(_restRequest, Method.POST); return response; }here I'm getting response and status code both, here can we redirect every request to access denied for 401 code