Search code examples
asp.net.netinternal-server-error

how to remove version information from server error "the resource cannot be found"


While browsing a page, I am getting the error :

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /WebResource.axd

Version Information: Microsoft .NET Framework Version:4.0; ASP.NET Version:4.0.33

The error is as expected and what i need is a way to hide/remove the version information.!? if there is any...


Solution

  • Create a custom page which you want your users to see and then in the web.config file have something like

    <system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="404.aspx" redirectMode="ResponseRedirect">
    <error statusCode="404" redirect="404.aspx" />
     ...
    </customErrors>
    </system.web>
    

    There are 3 different mode On, Off, RemoteOnly

    On - Specifies that custom errors are enabled. If no defaultRedirect attribute is specified, users see a generic error. The custom errors are shown to the remote clients and to the local host.

    Off - Specifies that custom errors are disabled. The detailed ASP.NET errors are shown to the remote clients and to the local host.

    RemoteOnly - Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host. This is the default value.

    The default is RemoteOnly further reading here. Also you might want to look at this answer if you want to know the difference between customErrors and httpErrors