Redirect from the OnException-method inside the controller with ASP.Net MVC

Posted by Eric Bartels

If your controller uses the HandleError-Attribute it handles exceptions thrown by action methods. I wanted to catch these exceptions and redirect to a custom error page. A simple RedirectToAction inside the OnException method does not work. But the ExceptionContext is all we need. #region Error handling protected override void OnException(ExceptionContext filterContext) { // Make use [...]

Problems with the ContentByQueryWebPart (CQWP) and its ItemXslLink-property

Posted by Eric Bartels

If you ever tried to set the ItemXslLink (which is a normal property of the ContentByQueryWebPart) you will see that sometimes this simply doesn’t work. You get an exception! Object reference not set to an instance of an object Why? The CmsDataFormWebpart.MakeSiteRelativeUrl (which is called somewhere when setting this property) needs the HttpContext.Current which isn’t [...]