Equivalent implementation for <customErrors mode = RemoteOnly / ">
From the msdn site, I know that the customErrors element provides information about custom error messages for ASP. NET RemoteOnly for the mode attribute indicates that user errors are displayed only to remote clients and that ASP.NET errors are displayed to the local host.
On the C # side, how can it be implemented that some logic calls only for remote clients, and the other for the local host (C # code that checks this condition will be called from the Global.asax.cs Application_Error level)?
I have found a solution.
I was not aware that the HttpRequest type has the IsLocal property. I checked the build of System.Web using dotPeek to implement System.Web.Configuration.CustomErrorsSection . I found using the IsLocal property for RemoteOnly mode. Its value indicates whether the request is from the local computer.
protected void Application_Error(object sender, EventArgs e) { if(Context.Request.IsLocal) { //do stuff } }