November Happy Hour will be moved to Thursday December 5th.

HandleError attribute

Vote:
 

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

#111734
Oct 20, 2014 11:40
Vote:
 

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

Frederik

#111741
Oct 20, 2014 12:52
Vote:
 

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:

        [HttpPost]
        [HandleError(ExceptionType = typeof(HttpAntiForgeryException), View = ServiceLocator.Current.GetInstance<UrlResolver>().GetVirtualPath(page.ContentLink))]
        [ValidateAntiForgeryToken]
        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?

#112068
Oct 22, 2014 12:20
Vote:
 

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

Frederik

#112070
Oct 22, 2014 12:49
Vote:
 

Thanks! I will try it out!

#112201
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.