Add the following to your web.config file within the <system.web>
node:
<customErrors mode="On" defaultRedirect="~/Error.cshtml" />
This will redirect the user to Error.cshtml (which you need to create) in the event of any ASP.NET error. You can change the mode value to RemoteOnly
during development, so that you can see the actual error message.
If you want a custom 404 page as well, you can do the following:
<customErrors mode="On">
<error statusCode="500" redirect="~/Error.cshtml" />
<error statusCode="404" redirect="~/404.cshtml" />
</customErrors>