public static void KraftResult(HttpContext httpContext, HttpStatusCode statusCode, string error = null) { httpContext.Response.StatusCode = (int)statusCode; switch (statusCode) { case HttpStatusCode.InternalServerError: { if (!string.IsNullOrEmpty(error)) { KraftLogger.LogCritical(error); } httpContext.Request.Headers.Clear(); break; } case HttpStatusCode.Unauthorized: { //HttpRequest request = httpContext.Request; httpContext.Response.StatusCode = StatusCodes.Status401Unauthorized; //string redirectUrl = string.Concat(request.Scheme, "://", request.Host.ToUriComponent(), request.PathBase.ToUriComponent(), request.Path.ToUriComponent(), request.QueryString.ToUriComponent()); //httpContext.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties() { RedirectUri = redirectUrl }); break; } default: { if (!string.IsNullOrEmpty(error)) { KraftLogger.LogError(error); } httpContext.Request.Headers.Clear(); break; } } }
public IActionResult Error() { IExceptionHandlerPathFeature exceptionHandlerPathFeature = HttpContext.Features.Get <IExceptionHandlerPathFeature>(); KraftLogger.LogCritical($"Method: public IActionResult Error for path: {exceptionHandlerPathFeature?.Path}", exceptionHandlerPathFeature?.Error); return(View()); }
private static void AppDomain_OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { KraftLogger.LogCritical("AppDomain_OnUnhandledException: ", e.ExceptionObject); }