In web.config > system.web
modes: On, Off, RemoteOnly
<!--On - display Views/Shared/Error.cshtml only rendered when there is an exception, 404 is not included in this custom error -->
<customErrors mode="RemoteOnly"></customErrors>
This applies whenever the server hits 500 or 404 errors. Not good in debugging but good in production. In system.webServer
<!--errorMode="DetailedLocalOnly" display only to remote clients-->
<!--errorMode="Custom" display to all both local and remote -->
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="404.html" responseMode="File" />
<error statusCode="500" path="500.html" responseMode="File" />
</httpErrors>
Note: adding the second block will override the first block