1

I can't seem to figure out how to custom handle this error. I have a endpoint defined like this:

[HttpGet] public ActionResult Test() { ... }

If I try to POST to this endpoint it throws the http 405 error which is correct. The problem is I want to provide a custom error page and not the IIS default one. I've tried breaking in the application_error method in global.asax but it never get's called, and I've tried adding the <customErrors /> section in web.config but to no avail.

Any suggestions?

1
  • Using firebug or the equivalent, do you see a 405 or a 500 status code in the browser? Commented Nov 15, 2011 at 3:58

1 Answer 1

1

Are you using MVC3? If so, watch out for

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
  filters.Add(new HandleErrorAttribute());
}

in your global.asax.

This filter will catch any exception thrown in a controller and make it a 500 response code. It will then try and find a View called "Error". Comment this out and customErrors will work as you expect.

Also, double check for [HandleError] attributes on the action method or controller you are using.

Sign up to request clarification or add additional context in comments.

1 Comment

I commented out the global filter and neither my action or controller have the attribute on it. Any other ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.