public IActionResult Error(int code) { // Get the details of the exception that occurred var exceptionFeature = HttpContext.Features.Get <IExceptionHandlerPathFeature>(); if (exceptionFeature != null) { // Get which route the exception occurred at var routeWhereExceptionOccurred = exceptionFeature.Path; // Get the exception that occurred var exceptionThatOccurred = exceptionFeature.Error; // TODO: Do something with the exception // Log it with Serilog? // Send an e-mail, text, fax, or carrier pidgeon? Maybe all of the above? // Whatever you do, be careful to catch any exceptions, otherwise you'll end up with a blank page and throwing a 500 } // Valida si el request fue Ajax if (HttpContext.Request.Headers["x-requested-with"] == "XMLHttpRequest") { return(new ObjectResult(ConvertHelpers.ErrorCodeToText(code))); } return(View()); // return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); }