Reputation: 89
I want to add a friendly error page to my application that would say a text like, "Oops some thing went wrong". I want the error page to be displayed automatically for every page of my application in the even of an exception. How can I achieve this?
Upvotes: 2
Views: 1907
Reputation: 1038710
Simply enable custom errors in web.config:
<customErrors mode="On">
</customErrors>
and the ~/Views/Shared/Error.aspx
view will be rendered on unhandled error (assuming your controller is decorated with the [HandleError]
attribute).
Then you can have more fine grained control and different views for different exceptions:
[HandleError(
View = "~/Views/Errors/Custom.aspx",
ExceptionType = typeof(SomeCustomException))]
Upvotes: 3