Visual Studio .NET - custom errors in web config file

Asked By asp csharp on 03-Oct-08 03:39 PM

 Hi all,

  Actually I uploaded my site first time.Iam getting the below error.Iam unable to understand this error.How can I clear this error and how can I go to my default page.Please can anybody help me out please as early as possible.

 <!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

check this - sri sri replied to asp csharp on 03-Oct-08 10:58 PM

Hi,
change the tag as below and check

<configuration>
    <system.web>   
<customErrors mode="On"/>
</system.web>
</configuration>

Read this - ram kumar replied to asp csharp on 04-Oct-08 12:28 AM

Hi,

Provides information about custom error messages for an ASP.NET application. The customErrors element can be defined at any level in the application file hierarchy.

<configuration> Element
  system.web Element (ASP.NET Settings Schema)
    <customErrors>

 
<customErrors defaultRedirect="url"
              mode="On|Off|RemoteOnly">
     <error. . ./>
</customErrors>


Attribute
 
Description
 
defaultRedirect
 
Optional attribute.

Specifies the default URL to direct a browser to, if an error occurs. When this attribute is not specified, a generic error is displayed instead.

The URL can be absolute (for example, http://www.contoso.com/ErrorPage.htm) or relative. A relative URL, such as /ErrorPage.htm, is relative to the Web.config file that specified the URL for this attribute, not to the Web page in which the error occurred. A URL starting with a tilde (~), such as ~/ErrorPage.htm, indicates that the specified URL is relative to the root path of the application.
 
mode
 Required attribute.

Specifies whether custom errors are enabled, disabled, or shown only to remote clients.

This attribute can be one of the following values.

Value
 Description
 
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.
 

Child Elements
Element
 Description
 
error
 Optional element.

Specifies the custom error page for a given HTTP status code.

The error tag can appear multiple times. Each appearance defines one custom error condition.
 

Parent Elements
Element
 Description
 
configuration
 Specifies the root element in every configuration file that is used by the common language runtime and the .NET Framework applications.
 
system.web
 Specifies the root element for the ASP.NET configuration settings in a configuration file and contains configuration elements that configure ASP.NET Web applications and control how the applications behave.
 

 
 

The following configuration example demonstrates how to specify the error handling pages to use for an ASP.NET application.

 Copy Code
<configuration>
  <system.web>
    <customErrors defaultRedirect="GenericError.htm"
                  mode="RemoteOnly">
      <error statusCode="500"
             redirect="InternalError.htm"/>
    </customErrors>
  </system.web>
</configuration>
 

what error message you are getting? - Perry replied to asp csharp on 04-Oct-08 01:30 AM

end of post
solution - Perry replied to asp csharp on 04-Oct-08 01:35 AM

Hi,

You problem's solution is here http://www.aspdev.org/articles/web.config/

<customErrors defaultRedirect="YourDefaultURL" mode="Off">
<error statusCode="ErrorStatusCode" redirect="YourRedirectURL"/>
</customErrors>

Also see http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx and http://www.c-sharpcorner.com/UploadFile/akukreja/CustomErrorHandlingASPNET11142005235614PM/CustomErrorHandlingASPNET.aspx

Regards,

Megha

karmela replied to sri sri on 21-Jul-10 01:31 AM
how will i do this????