is it possible to change the default error location page from Shared/Error.cshtml to Errors/Default.cshtml? I am trying to organize a big project and would prefer if I could use my organization schema.
Thanks
is it possible to change the default error location page from Shared/Error.cshtml to Errors/Default.cshtml? I am trying to organize a big project and would prefer if I could use my organization schema.
Thanks
You can setup the customErrors in the web.config to redirect to an ErrorController:
<customErrors mode="RemoteOnly" defaultRedirect="~/Error">
<error statusCode="404" redirect="~/Error/NotFound" />
</customErrors>
Then you can customize the error view to your liking.
By default you get the HandleErrorAttribute filter in your MVC application. It is executed when an unhandled exception is thrown. I think it sets the view as Error. That's why it sits in the Shared folder, as it's accessible from all the controllers.
To achieve what you want you have to subclass HandleErrorAttribute and override relevant logic.