I would suggest using the following property:
HttpContext.Current.IsCustomErrorEnabled
As mentioned here, IsCustomErrorEnabled takes more things like RemoteOnly into consideration:
The IsCustomErrorEnabled property combines three values to tell you
whether custom errors are enabled for a particular request. This isn't
as simple as reading the web.config file to check the
section. There's a bit more going on behind the scenes to truly
determine whether custom errors are enabled.
The property looks at these three values:
The web.config's < deployment > section's retail property. This is a
useful property to set when deploying your application to a production
server. This overrides any other settings for custom errors.
The web.config's < customErrors > section's mode property. This setting
indicates whether custom errors are enabled at all, and if so whether
they are enabled only for remote requests.
The HttpRequest object's IsLocal property. If custom errors are enabled only for remote
requests, you need to know whether the request is from a remote
computer.
answered 2013-02-01T02:17:58.593