How to Test a Web Application - How to test a web application
(Page 2 of 4 )
After you design the forms and develop the code for a web application, you need to test it to be sure it works properly. Then, if you discover any errors in the application, you can debug it, correct the errors, and test it again.
In chapter 4, you’ll learn all the skills you need to test and debug a web application. For now, I just want to show you how to run a web site with the built-in development server so you can test any applications that you develop for this chapter. Then, I’ll show you the HTML code that’s sent to the browser so you can see how that works.
How to run a web site with the built-in development server
When you run a file-system web site by using one of the techniques in figure 2-18, Visual Studio 2008 compiles the application. If the application compiles without errors, Visual Studio automatically launches the built-in ASP.NET Development Server and displays the starting page of the web site in your default browser. Then, you can test the application to make sure that it works the way you want it to.
However, if any errors are detected as part of the compilation, Visual Studio opens the Error List window and displays the errors. These can consist of errors that have to be corrected as well as warning messages. In this figure, five errors are displayed in the Error List window. These errors occurred because I set the Option Strict option on.
To fix an error, you can double-click on it in the Error List window. This moves the cursor to the line of code that caused the error in the Code Editor. By moving from the Error List window to the Code Editor for all of the messages, you should be able to find the coding problems and fix them.
Note that the code that caused the errors is also identified with a wavy underline in the Code Editor. In fact, the errors shown here were highlighted before I compiled the application. Visual Studio doesn’t detect some errors until the application is compiled, though.
If a bar appears at the right end of the wavy underline that identifies an error, it means that the Smart Compile Auto Correction feature is available. Then, you can place the mouse pointer over this bar to display a smart tag, and you can click the drop-down arrow that appears to display an Error Correction Options window like the one shown in this figure. This window includes a description of the error, suggestions for correcting the error, and a preview of how the code will look if you apply the corrections. If you like a suggested correction, you can just click on it to apply it.
As you’re testing an application with the development server, exceptions may occur. If an exception isn’t handled by the application, ASP.NET switches to the Code Editor window and highlights the statement that caused the exception. In this case, you can end the application by clicking on the Stop
An ASP.NET project with the Error List window displayed

How to run an application
Click on the Start button in the Standard toolbar or press F5. Then, the project is compiled and the starting page is displayed in your default browser.
The first time you run an ASP.NET application, a dialog box will appear asking whether you want to modify the web.config file to enable debugging. Click the OK button to proceed.
How to stop an application
How to fix syntax errors
If any errors are detected when the project is compiled, an Error List window is opened and a list of errors is displayed along with information about each error. To display the source code that caused an error, double-click on the error in the Error List window.
Syntax errors are highlighted in the Code Editor window with a wavy underline. If a bar appears at the right end of the underline, you can place the mouse pointer over the bar, then over the smart tag that’s displayed, and click the drop-down arrow to display the Error Correction Options window.
To correct an error, you can click the appropriate “Replace…” link in the Error Correction Options window, or you can enter the correction yourself.
--------------------------------------------Figure 2-18 How to run a web site with the built-in development server
Debugging button in the Debug toolbar or using the Debug->Stop Debugging command. Then, you can fix the problem and test again.
In chapter 4, you’ll learn all of the debugging skills that you’ll need for more complex applications. For simple applications, though, you should be able to get by with just the skills you have right now.
Next: How to review the HTML that’s sent to the browser >>
More ASP.NET Articles
More By Murach Publishing
|
This article is an excerpt from chapter two of Murach's ASP.NET 3.5 Web Programming with VB 2008, written by Anne Boehm (Murach, 2008; ISBN: 1890774472). Check it out today at your favorite bookstore. Buy this book now.
|
|