2

In my MVC project i set a Default error page in the web.config

<customErrors defaultRedirect="~/Error/Index" mode="RemoteOnly">
</customErrors>

till now all is fine, in any exception thrown the user get the default error page.

Now i want to add another error page that in specific exception will load instead of the default error page that set in the web.config.

I had an idea: maybe in a new class that inherit "ActionFilterAttribute" and implement "IExceptionFilter", i will in any exception thrown from an action if the type of the exception is my specific case, in this case i need to change the redirect route that set in the web.config as default, but how can i do it? or maybe someone have an another idea?

gdoron is supporting Monica
  • 142,542
  • 55
  • 282
  • 355
Kobi
  • 181
  • 1
  • 2
  • 10

3 Answers3

0

You don't need to change anything in the web.config. The customErrors in the catches only the exceptions you didn't catch in yours ActionFilters and Controllers.

Good plan Boss!

gdoron is supporting Monica
  • 142,542
  • 55
  • 282
  • 355
0

enter image description here

And read this SO Answer about how I do it, etc. It might help :)

Community
  • 1
  • 1
Pure.Krome
  • 82,011
  • 105
  • 379
  • 615
0

You can specify what views are rendered for a given exception with the HandleErrorAttribute filter

hawkke
  • 4,182
  • 1
  • 26
  • 23