Error handling does not work

0

In the config of my application I deleted the customErrors to do a test of an error that is difficult to replicate.

And where the error should be I put a try:

if (ModelState.IsValid)
        {
            db.TarefaHoras.Add(tarefaHora);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                ErroDetalhe erro = new ErroDetalhe();
                erro.Data = tarefaHora.Data;
                erro.UsuarioId = tarefaHora.ApplicationUserId;
                erro.JSON = JsonConvert.SerializeObject(tarefaHora);
                erro.Tipo = "TarefaHora";
                erro.Controller = "TarefaHoras";
                erro.Action = "Create Post";
                erro.Exception = ex.GetType().FullName;

                db.ErroDetalhes.Add(erro);
                db.SaveChanges();

                return RedirectToAction("ErroNaAtualizacaoDaBase", "Erros", new { id = erro.ID });                        
            }

            return RedirectToAction("Index", "Home");
        }

        ViewBag.TipoTarefaID = new CBMMSapp.DAO.TiposTarefaDAO().ListaParaDropDown();
        ViewBag.ApplicationUserId = new CBMMSapp.DAO.UsuariosDAO().ListaParaDropDown(tarefaHora.ApplicationUserId);
        ViewBag.ClienteID = new CBMMSapp.DAO.ClientesDAO().ListaParaDropDown();
        return View(tarefaHora);
    }

This error only happens at runtime and only on the Azure server, so my attempt was to get a better description of the error and for this I created a table where the information is deposited.

But ....

The problem is that the View error that I'm getting is not the View View Error in the UpdateBase I created and that is redirected in Catch.

This is the default AspNET error view.

So I went into the Shared views and deleted the default page and removed the custom.rules from web.config.

And yet Azure still brings the default error view.

Does anyone have any idea what might be happening?

    
asked by anonymous 01.04.2017 / 15:14

1 answer

0

Hello,

A simple way to validate your StackTrace error is to enable the FREB Logs in your App Service.

  

FREB LOGS: Detailed information about failed requests, including a trace of the IIS components used to process the request and the time taken in each component. This can be useful if you are trying to improve site performance or isolate what is causing the return of a specific HTTP error.

  • On the portal, go to the desired app service slot and then navigate to: Settings > Diagnostic Logs

  • EnabletheFailedrequesttracingoption.

  • InthedesiredserviceappslotbrowsetoDiagnoseandsolveproblems
  • AtthetopselecttheTroubleshootoptionandinthelistofTools,selectFREBlogs
  • Anewscreenwillbeloadedandinthelistingwecanaccessvariousinformation,includingtheIISdetailxmlontheerror.

Formoredetails: link

    
06.04.2017 / 18:15