HandleError attribute


Is the HandleError attribute used for Controllers and/or Actions applicable for EPiServer MVC applications? Can't figure out how to use it...

Oct 20, 2014 11:40

You need to register it to activate it, either globally or on your controller, like with any ASP.NET MVC application. More information: http://msdn.microsoft.com/en-us/library/system.web.mvc.handleerrorattribute(v=vs.118).aspx


Oct 20, 2014 12:52

I have activated it and I have been able to show an error page. But is there a possibility to choose an action or controller or an url to a page like this:

        [HandleError(ExceptionType = typeof(HttpAntiForgeryException), View = ServiceLocator.Current.GetInstance<UrlResolver>().GetVirtualPath(page.ContentLink))]
        public ActionResult Index(EmployeePage currentPage, EmployeeModel.EmployeeFormDataModel employeeFormData)

This of course doesn't work but is it possible to do something like this?

Or do the error page has to be a static page?

Oct 22, 2014 12:20

I would just create a custom HandleError attribute (that inherits from HandleErrorAttribute) and override the OnException method (and add your redirect logic there).


Oct 22, 2014 12:49

Thanks! I will try it out!

Oct 24, 2014 13:09
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.