ASP.NET and the .NET Framework - Visual Studio .NET
(Page 3 of 6 )
Since all the ASP.NET source files are plain text, you can develop all your web applications using your favorite text editor. In fact, many of the examples in this book are presented just that way. However, Visual Studio .NET, the integrated development environment released in conjunction with the .NET Framework, offers many advantages and productivity gains. These include:
- IntelliSense and automatic code completion
- Integrated debugging
- Automated build and compile
- Integration with the Visual SourceSafe source control program
- Fully-integrated, dynamic help
Chapter 2 discusses Visual Studio .NET fully.
Hello World It is a long-standing tradition among programmers to begin the study of a new language by writing a program that prints “Hello World” to the screen. In deference to tradition, our first web page will do just that.
The tool you are most likely to use when developing ASP.NET applications is an integrated development environment (IDE), such as Visual Studio .NET. However, you may use any editor you like—even the venerable text editor Notepad.
There are a number of advantages to using an IDE such as Visual Studio .NET. The Visual Studio .NET editor provides indentation and color coding of your source code, the IntelliSense feature helps you choose the right commands and attributes, and the integrated debugger helps you find and fix errors in your code.
The disadvantage of using an IDE, however, is that it may do so much work for you that you don’t get a good feel for what is going on in your application. It is like bringing your car in to the mechanic. He does all the work for you, but you never really learn how your engine works.
As a beginner, you may be better off doing more of the work yourself, giving up the support of the IDE in exchange for the opportunity to see how things really work. In this chapter, you will use a simple text editor to create the source code for the first several iterations. At the end of the chapter, you will use Visual Studio .NET to create the same web page. (For the remainder of the book, you will find both examples that are created using a text editor and examples that are developed in Visual Studio .NET.)
Back in the old days, before ASP and ASP.NET, web pages were created with simple HTML. To better appreciate the features of ASP.NET, you will first create the Hello World web page in HTML, then convert it to ASP, and finally convert it to ASP.NET.
The HTML Version Straight HTML provides a means of creating and presenting static web pages. This book is not a tutorial on how to write HTML,and we assume you know enough HTML to follow the simple examples provided. For background reading,see HTML: The Definitive Guide,by Chuck Musciano and Bill Kennedy (O’Reilly). To get
A Word About the Samples in This Book In real life, web sites run from a web server, which is typically a separate machine (or machines) running a web server program, such as Microsoft Internet Information Server (IIS). In that case, a browser makes a request to the server, which processes the request and sends HTML back to the browser.
If you have a web server available, you could certainly put the samples from this book on the server and run them that way. Suppose the server domain name is MyServer.com and the web page you want to test is HelloWorld.htm, which is located in the virtual root directory of the web server. The URL to be entered in your browser would be:
www.MyServer.com/HellowWorld.htm
It’s easier to do your development and testing on a single machine, then deploy to a web server for final testing and production. You must have IIS set up on your local machine.
IIS (the name has evolved to Internet Information Services) is included with Windows 2000 Professional and Windows XP Professional. It is not installed by default, although it can be installed if a custom Win2K/WinXP installation is performed. It can also be installed at any time by going to Control Panel, selecting Add/Remove Programs, and clicking on the Add/Remove Windows Components button.
To access the virtual root of a local copy of IIS, the URL should refer to localhost. By default, localhost points to the physical directory c:\inetpub\wwwroot.
Typically, you will define other virtual directories using Internet Services Manager (found in Control Panel Administrative Tools). These virtual directories can be subdirectories anywhere on the local machine. If you have a directory defined on your C drive named c:\myProjects, you can define a virtual directory named projects that you “point” to that directory. If your HelloWorld.htm file is located in c:\myProjects,then the URL to enter in your browser would be:
localhost/projects/HelloWorld.htm
For now, you will create a subdirectory called c:\projects\Programming ASP.NET. Then you will use Internet Services Manager to define a virtual directory, called ProgAspNet, pointing to that location. If the HTML file you want to run, HelloWorld.htm, is in that directory, then the URL to enter in your browser will be:
localhost/ProgAspNet/HelloWorld.htm
started, create a very simple Hello World HTML file, as shown in Example 1-1, and call it
HelloWorld1.htm. The output is shown in Figure 1-2.
Example 1-1. Code listing for HelloWorld1.htm
<htm1>
<body>
<h1>Hello World</h1>
</body>
</htm1> 
Figure 1-2. Output from Example 1-1
The HTML page displays the static text, using the HTML heading1 format. If you want to include dynamic content, such as the results of a query against a database or even the current time, then a static HTML page is not the thing to use. For that you need some sort of server processing. There are a number of alternatives; we will focus on ASP and then on ASP.NET.
Next: The ASP Version >>
More ASP.NET Articles
More By O'Reilly Media
|
This article is excerpted from Programming ASP.NET by Jesse Liberty and Dan Hurwitz (O'Reilly, 2003; ISBN 0596004877). Check it out at your favorite bookstore today. Buy this book now.
|
|