0
Guys, the following is, in my application I would like to see a page with the error occurred, but that this page has all the formatting proposed in the layout, so this is not happening, because it only generates a blank page with the error code. Below the code I’m using:
No homeController:
public ActionResult ExemploErroNaoMapeado()
{
var response = new ResponseViewModel();
try
{
throw new Exception("Oops, ocorreu um erro");
}
catch (Exception e)
{
return ErroCapturado(e);
}
return Json(response, JsonRequestBehavior.AllowGet);
}
public ActionResult ErroCapturado(Exception ex)
{
var response = new ResponseViewModel
{
Data = ex.Data,
Sucesso = false,
Mensagem = ex.Message
};
return Json(response, JsonRequestBehavior.AllowGet);
}
In manageViewModels added:
public class ResponseViewModel
{
public object Data { get; set; }
public bool Sucesso { get; set; }
public string Mensagem { get; set; }
}
And the page that should display the error ta so:
<h2>
Ocorreu um erro não mapeado durante a execução
da última ação...
</h2>
<script type="text/javascript">
$(document).ready(function () {
//debugger;
gerandoRelatorio();
function gerandoRelatorio() {
$.getJSON("Home/ExemploErroNaoMapeado", function (response) {
if (response.sucesso) {
console.log(response.data);
}
else {
alert(data.mensagem);
}
}).fail(function (response) {
//Erro genérico
alert("Não foi possível processar a sua requisição");
});
}
});
</script>
So I want to know, how to make the layout work on this page, since it loads all blank and doesn’t even bring the menu together?
With the changes suggested by the friend below this error appears:
Failed, error appeared "Runtime Error Description: An Exception occurred while Processing your request. Additionally, Another Exception occurred while executing the custom error page for the first Exception. The request has been terminated. "
– WPfan
Which Exception? Could you put an image of it, or add your question to the details of Exception?
– Grupo CDS Informática
I edited the question putting the image of error, see there.... face this is breaking my head.... I know what to do, even more than I’m starting now with C#, I came from PHP!
– WPfan
Go debug the code, and when you give the Exception, put the stacktrace on it, please.
– Grupo CDS Informática