Jan 07, 2015, 5:46 PM
Custom error management
Hi all,
I have a MVC Ext.NET web project.
I do a base controller with the following code :
The Home Page has the following method :
Why the exception is not raised when in instanciate it?
Thanks in advance,
Simone
I have a MVC Ext.NET web project.
I do a base controller with the following code :
public class BaseController : Controller
{
protected override void OnException(ExceptionContext filterContext)
{
base.OnException(filterContext);
if (filterContext.Exception.GetType().Equals(typeof(ModPastiUserNotExistException)))
{
ViewBag.CurrentErrorMessage = filterContext.Exception.Message;
filterContext.ExceptionHandled = true;
ErrorModel errorInfo = new ErrorModel(filterContext.Exception, "ErrorController", "Index");
errorInfo.Titolo = "Autenticazione";
errorInfo.Messaggio = filterContext.Exception.Message ;
filterContext.Result = View("error", errorInfo);
}
else
{
ViewBag.CurrentErrorMessage = filterContext.Exception.Message;
filterContext.ExceptionHandled = true;
ErrorModel errorInfo = new ErrorModel(filterContext.Exception, "ErrorController", "Index");
errorInfo.Titolo = "Errore";
errorInfo.Messaggio = filterContext.Exception.Message;
filterContext.Result = View("error", errorInfo);
}
}
}
All the controllers of the app derive from base controller.The Home Page has the following method :
public ActionResult Index()
{
if (UserPermission.Instance.UserExist(HttpContext))
{
return View();
}
else
{
throw new ModPastiUserNotExistException();
}
}
I implemented both the error/index.cshtml and the ErrorController.cs and also the specialized exception.Why the exception is not raised when in instanciate it?
Thanks in advance,
Simone