How to Troubleshoot a Runtime Error in ASP.NET

A runtime error occurs in ASP.NET when the application encounters a problem in logic that violates the rules of the Common Language Runtime (CLR) assembly. All .NET applications involve a process known as just-in-time (JIT) compiling, wherein the web application is compiled into a runtime library that is then executed by the .NET framework installed on the web server. Two common ways to troubleshoot rutime errors are by modifying the application web.config file or performing exception handling within code.

Things You'll Need

  • Visual Studio or Visual Web Developer Express
Show More

Instructions

  1. Modify the web.config File

    • 1

      Navigate to the root of the directory on the web server where the application resides.

    • 2

      Locate the "web.config" file in the list of files.

    • 3

      Open the "web.config" file using Visual Studio or Notepad.

    • 4

      Locate the "<system.web>" tag.

    • 5

      Below the "<system.web>" tag, type:

      <customErrors mode="Off" />

    • 6

      Save changes to the file and exit; run the application and view the details of the error that will assist you in finding a resolution.

    Perform Error Exception Handling in Code

    • 7

      Open the web site file or project in Visual Studio (or Visual Web Developer Express).

    • 8

      Locate the section of code that executes when the error occurs (e.g., this might be on the Page_Load event or in response to some other event, such as the click of a button).

    • 9

      Enclose the code that executes inside of a "try" block as follows:

      try

      {

      ...enclose all code here...

      }

    • 10

      Below the "try" block, type:

      catch (Exception ex)

      {

      Response.Write(ex.Message.ToString());

      }

    • 11

      Save the changes in the program and close.

    • 12

      Run the ASP.NET application and observe the messages displayed through the exception handling code. This should provide details of the error that will assist you in finding a resolution.

Related Searches:

References

Resources

Comments

You May Also Like

Related Ads

Featured