Server Error in ‘/’ Application
- current custom error settings prevent remote viewing of the application error details for security reasons.
- To enable remote viewing of this specific error message, create a tag within a "web.config" configuration file located in the root directory of the current web application.Set the...
- The current error page can be replaced with a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error...
Runtime error
Table of Contents
Description
An request error has occurred on the server. current custom error settings prevent remote viewing of the application error details for security reasons. Though, these details can be viewed by browsers running on the local server machine.
Details
To enable remote viewing of this specific error message, create a <customErrors> tag within a “web.config” configuration file located in the root directory of the current web application.Set the “mode” attribute of this tag to “Off”.
<customErrors mode="Off" />
Notes
The current error page can be replaced with a custom error page by modifying the “defaultRedirect” attribute of the application’s <customErrors> configuration tag to point to a custom error page URL.
Runtime Error in Web Applications: A Troubleshooting Guide
What is a Runtime Error?
A runtime error, specifically in the context of web applications, is a server-side error that occurs while the submission is running. Unlike compile-time errors, which are caught during the advancement phase, runtime errors manifest when the application is executed, typically when a user interacts wiht the application. These errors can disrupt the user experience and prevent the application from functioning as intended.
Why am I Seeing a “Server Error” Page?
When a runtime error occurs, the web server often displays a generic “Server Error” page instead of the detailed error information. This is frequently due to security configurations designed to prevent sensitive details about the application’s inner workings from being exposed to the public. The default behaviour is to hide the error details for remote users. However, you can modify this behavior if you need to view the details locally.
How to View Detailed Runtime Error Information on the Local Server
To view detailed error messages on the server machine, you need to modify the application’s web.config file.
- locate the
web.configfile: This file is typically found in the root directory of your web application. - Add or Modify the
Tag: If thetag doesn’t exist, add it. If it exists, modify its attributes. - Set the
modeAttribute: Set themodeattribute to “Off”. This setting instructs the server to display detailed error information, instead of the default error or your custom error pages.
xml
mode="off": Displays detailed error messages, useful for development and debugging on the local server. Vital: Do not use this setting in a production habitat due to security risks.
mode="remoteonly": (Default setting) Shows custom error pages to users accessing the application remotely, while displaying detailed error information on the local server.
mode="On": Displays custom error pages to all users, regardless of whether they are local or remote.
- Save the
web.configfile: after making the changes, save the file. The web server should automatically detect the changes, and the detailed error messages should appear when you refresh the page on your local server. In some cases, you may need to restart the application or the server.
Can I Customize the Error Page?
Yes,you can replace the default error page with a custom error page to provide a more user-friendly experience. To do this, you can modify the defaultRedirect attribute of the tag.
- Create a Custom Error Page: Design and create an HTML page that you want to display when an error occurs. This page should contain information and links, such as information on how to contact support, or provide a friendly message to the user.
- Modify the
tag:
xml
defaultRedirect: Specifies the URL of your custom error page. The tilde (~) character represents the root directory of your application.
* You can optionally specify error pages for certain status codes like 404 (Not Found) or 500 (Server Error), making for more specific messaging.
- Save the
web.configfile: Save the modified web.configfile.Upon the occurrence of an error,the user will now be redirected to your custom error page.
Best Practices for Error Handling and custom Error Pages
Here’s a summary of best practices:
| Feature | Description | Benefit |
| —————— | ———————————– | ———————————————————– |
| Detailed Errors (local) | Enable detailed errors | Debugging on local Server |
| custom Error Pages | Implement custom error pages.| Improve user experience, branding and provide helpful links |
| Logging | Log all errors. | Error monitoring and debugging |
| Security | Use safe practices. | Protect your data |
Conclusion
Runtime errors are a common part of web application development. By understanding how to configure error handling and customize error pages, you can improve both the user experience and your ability to troubleshoot issues effectively.
