Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article explains various ways to debug pages in an ASP.NET Web Pages (Razor) website. Debugging is the process of finding and fixing errors in your code pages.
What you'll learn:
- How to display information that helps analyze and debug pages.
- How to use debugging tools in Visual Studio.
These are the ASP.NET features introduced in the article:
- The
ServerInfohelper.ObjectInfohelper.Software versions
- ASP.NET Web Pages (Razor) 3
- Visual Studio 2013
This tutorial also works with ASP.NET Web Pages 2. You can use WebMatrix 3 but the integrated debugger is not supported.
An important aspect of troubleshooting errors and problems in your code is to avoid them in the first place. You can do that by putting sections of your code that are likely to cause errors into try/catch blocks. For more information, see the section on handling errors in Introduction to ASP.NET Web Programming Using the Razor Syntax.
The ServerInfo helper is a diagnostic tool that gives you an overview of information about the web server environment that hosts your page. It also shows you HTTP request information that's sent when a browser requests the page. The ServerInfo helper displays the current user identity, the type of browser that made the request, and so on. This kind of information can help you troubleshoot common issues.
Create a new web page named ServerInfo.cshtml.
At the end of the page, just before the closing