Esempio n. 1
0
        public IActionResult Index()
        {
            var feature = HttpContext.Features.Get <IExceptionHandlerFeature>();
            var error   = feature?.Error;

            if (error != null)
            {
                if (error is ForbiddenException)
                {
                    return(RedirectToAction("AccessDenied", "User"));
                }
                else if (error is NotFoundException)
                {
                    return(RedirectToAction("NotFound"));
                }
                else if (error is UnauthorizedException)
                {
                    return(RedirectToAction("Logout", "User"));
                }
                else
                {
                    var task = ErrorService.CreateError(new AppErrorModel(error, MyUser?.UserId.ToString(), "global error handler"));
                }
            }

            return(View(new ErrorViewModel {
                RequestId = System.Diagnostics.Activity.Current?.Id ?? HttpContext.TraceIdentifier
            }));
        }