Hi,
We’ve had a handler with an implementation for IPageNotFoundResolver for a while now. It’s been doing what it’s supposed to, but the same cannot be said about IErrorPageResolver. It’s never been displayed when errors happen. Was the intention that the ErrorPageResolver should be called when an unhandled exception occur in the application? Is there something else you need to do to implement it? I’ve followed the documentation I could find.
Error pages in ASP.NET MVC have always been a bit tricky, and I might end up implementing a catch all handler in Global.asax instead. Running calls to the CMS in an error handler might not be the best… if for some reason the problem lies in database connection etc. But still wanted to understand what is missing from the implementation.
When I testing both the error handler and page not found handler is catching and processing correct page.
I used this dummy handler to trigger different errors in accelerator
using System;
using System.Web.Mvc;
namespace Litium.Accelerator.Mvc.Controllers
{
public class TestHandlerController : Controller
{
public ActionResult Index()
{
return Content(@"<html><head></head><body><ul>
<li><a href='./TestHandler/error'>Error</a></li>
<li><a href='./TestHandler/NotFound1'>Not found 1</a></li>
<li><a href='./TestHandler/NotFound2'>Not found 2</a></li>
<li><a href='/dummy-that-not-should-exists'>Never not found</a></li>
</ul></body></html>");
}
public ActionResult Error()
{
throw new Exception("My silly mistake");
}
public ActionResult NotFound1()
{
return HttpNotFound();
}
public ActionResult NotFound2()
{
return new HttpStatusCodeResult(404);
}
}
}
After compiled and browsed into https://mydomain.localtest.me/site.axd/TestHandler the handler was responding with the index-data.
For each click on the links the resulted page was responding with correct information.
When you are developing on local machine it is important to change the customeErrors[@mode] in web.config to On, otherwise the error handler is not executed as it should.
I thought I had tried flipping “customErrors”… but obviously not… (facepalm). That almost fixed it for me.
It’s now displaying the 404 instead of yellow page of death.
But it’s most certainly something else causing that. I have the same code as the accelerator fetching the page GetFirstPublishedPage. Going to debug a bit, and probably accept your answer after fixing the last bit.