C# .NET - run time error - Asked By hiren dhameliya on 19-Dec-11 05:35 PM

hi i create my website and i upload to server and it shows me someting like this error please reply me as soon as possible

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

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

        <customErrors mode="Off"/>

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 -->

        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
Riley K replied to hiren dhameliya on 19-Dec-11 07:55 PM

Specify this in your Web.Config file

<customErrors mode="Off"/ 

  <customErrors mode="Off"/>
  <compilation debug="true"/>
  <authentication mode="None"/>

If you already set the CustomerErrors to "Off" (note that O is capital O) and you still get this message, the problem is very well be related to the web.config file.  If the web.config file has a problem, it defaults to the customError specified in the root web.config.

When you load the page, scroll down to the bottom and check to make sure the ASP.NET version is 2.0

If this still doesn't work, ask your host to execute the page on the server.  They should give em the real error.

smr replied to hiren dhameliya on 19-Dec-11 09:03 PM

Change your web.config file (website root).
edit or Add if there is no customErrors entry 
<customErrors mode="Off"/>

So you can see the REAL error message

In order to get this working, the folder containing the web.config file should be marked in IIS as an application (via inetmgr, properties of the folder, "Create Application" button)
. When the custom errors are disabled, you'll get detailed information about the error that occurred (information about the exception itself).

Web Star replied to hiren dhameliya on 19-Dec-11 10:32 PM
This error itself describe you can't see actual error until unless you change the customErrors mode to set off
When you turn change it to off in web.config, you will get actual error.

Most of the time when you getting this error in case of  upload that is file read/write permission problem on the upload folder
Jitendra Faye replied to hiren dhameliya on 19-Dec-11 11:28 PM

The error page is telling you that your web.config file (located in the root folder of the web site) is not configured to allow error information to be viewed "remotely," which is to say, from any source other than the local machine. Here is the part of the page you are having trouble understanding:

<!-- Web.Config Configuration File --> 
    <customErrors mode="Off"/>  

What this means is that when you open your web.config file, you look for a section called "configuration," under which is another section called "system.web." Note that this doesn't necessarily mean that the "system.web" section is directly below the start tag, but somewhere inside that "configuration" section. If there is no "customErrors" element inside the "system.web" section, you can simply copy the one above and paste it between the start and end tags of the section. Otherwise, find the "customErrors" element, and replace it with the one above. This will allow you to see the actual error message from the ASP.net application. Hopefully, then you will be able to solve the issue.
Suchit shah replied to hiren dhameliya on 19-Dec-11 11:53 PM
This error might occur due to two scenarios.

1. There is an error in the application's logic with the inputformat, Type etc., and you have set the Custom Error Mode in the web.config to "On" and not specified a default redirect error page.

2. The web.config file is not well formed or having invalid characters and the application is not able to pick up the settings from the same.


1. Set the custom error mode to "Off" to view the error. After rectifying it and before deployment, change it to "On" and specify a default error page, as follows:-

< customErrors defaultRedirect="ErrorPage.aspx" mode="On">

< /customErrors>

such that your users will not be able to see the actual error and get your friendly error page where you can politely say "An error has occured! Sorry for the inconvenience ..." .

2. If the above solution is not working (i.e. even after setting the custom error mode to On, the same "Server Error" occurs, then the likely chance is that your web.config file is not well formed and has invalid characters etc.,

To resolve, it copy paste the contents of the file to a notepad, save it as an xml file and try to browse the xml file in the browser. If the xml file is unable to be rendered by the browser and throws error, then you can find the place where the tags are not well formed or invalid character(s) exist and rectify them.

Things worth noting is Web.config is case sensitive and even trailing / leading spaces can cause the above error.