Custom error management

  1. #1

    Custom error management

    Hi all,
    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
  2. #2
    Hi,

    Since this is not directly related to ext.net I think other online resources are much more valuable, for example: http://www.devcurry.com/2012/06/aspn...s-and-404.html (source: MVC Recommended Resources).
  3. #3

    [CLOSED] Custom error management

    I solved the issue.
    Thanks,
    Simone

Similar Threads

  1. [CLOSED] DirectMethod heartbeat task and State management
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Sep 20, 2012, 8:44 PM
  2. [CLOSED] Session management problem in IE8
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Jun 13, 2012, 8:44 PM
  3. Concerned about memory management
    By dbassett74 in forum 1.x Help
    Replies: 3
    Last Post: Nov 16, 2009, 4:33 PM
  4. Print job management for web applications
    By Nime in forum Open Discussions
    Replies: 1
    Last Post: Aug 04, 2009, 10:12 AM
  5. Window management best practices
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: Apr 20, 2009, 8:24 PM

Tags for this Thread

Posting Permissions