Professional VB 2005 with .NET 3.0 (Programmer to Programmer)
If you are new to ASP.NET and building your first set of applications in ASP.NET 2.0, you may be amazed by all the wonderful new server controls it provides. You may marvel at how it enables you to work with data more effectively using the new data providers, and you may be impressed at how easily you can build in security and personalization.
The outstanding capabilities of ASP.NET 2.0 do not end there, however. This section looks at many exciting additions that facilitate working with ASP.NET pages and applications. One of the first steps you, as the developer, should take when starting a project is to become familiar with the foundation you are building on and the options available for customizing that foundation.
Application Location Options
With ASP.NET 2.0, you have the option - using Visual Studio 2005 - to create an application with a virtual directory mapped to IIS, or a standalone application outside the confines of IIS. Whereas Visual Studio .NET forced developers to use IIS for all Web applications, Visual Studio 2005 (and Visual Web Developer Express Edition, for that matter) includes a built-in Web server that you can use for development, much like the one used in the past with the ASP.NET Web Matrix.
Tip | This built-in Web server was previously presented to developers as a code sample called Cassini. In fact, the code for this mini Web server is freely downloadable from the ASP.NET team website found at www.asp.net. |
The Built-In Web Server
By default, Visual Studio 2005 builds applications without the use of IIS. You can see this when you select New Web Site in the IDE. By default, the location provided for your application is C:\Documents and Settings\[user]\My Documents\Visual Studio 2005\WebSites (shown in Figure 19-3). It is not C:\Inetpub\wwwroot\ as it would have been in Visual Studio .NET 2003/2002. By default, any site that you build and host inside C:\Documents and Settings\[user]\My Documents\Visual Studio 2005\WebSites (or any other folder you create) uses the built-in Web server that is part of Visual Studio 2005. If you use the built-in Web server from Visual Studio 2005, you are not locked into the Websites folder; you can create any folder you want in your system.
To change from this default, you have a handful of options. Click the Browse button in the New Web Site dialog. This brings up the Choose Location dialog, shown in Figure 19-4.
If you continue to use the built-in Web server that Visual Studio 2005 provides, you can choose a new location for your Web application from this dialog. To do so, select a new folder and save your .aspx pages and any other associated files to this directory. When using Visual Studio 2005, you can run your application completely from this location. This new way of working with the ASP.NET pages you create is ideal if you don’t have access to a Web server, as it enables you to build applications that don’t reside on a machine with IIS. This means you can develop ASP.NET applications on operating systems such as Windows XP Home Edition.
IIS
From the Choose Location dialog, you can also change where your application is saved and which type of Web server your application employs. To use IIS (as you probably did when you used Visual Studio .NET 2003/2002), click the Local IIS button. This changes the text area to show you a list of all the virtual application roots on your machine.
To create a new virtual root for your application, highlight Default Web Site. Two accessible buttons appear at the top of the dialog (see Figure 19-5). Looking from left to right, the first button in the upper-right corner of the dialog is for creating a new Web application - or a virtual root. This button is shown as a globe inside a box. The second button enables you to create virtual directories for any of the virtual roots you create. The third button is a delete button, which enables you to delete any selected virtual directories or virtual roots on the server.
After you have created the virtual directory you want, click Open. Visual Studio 2005 then goes through the standard process to create your application. But now, instead of depending on the built-in Web server from ASP.NET 2.0, your application will use IIS. When you invoke your application, the URL now consists of something like http://localhost/myweb/default.aspx, which means it is using IIS.
FTP
Not only can you decide on the type of Web server for your Web application when you create it using the Choose Location dialog, you can also decide where to locate your application. The previous options built applications that resided on your local server. The FTP option enables you to actually store and even code your applications while they reside on a server somewhere else in your enterprise - or on the other side of the planet. You can also use the FTP capabilities to work on different locations within the same server. This new built-in capability provides a wide range of possible options and represents a major enhancement to the IDE. Previously difficult to accomplish, this task is now quite simple, as illustrated in Figure 19-6.
To create your application on a remote server using FTP, simply provide the server name, the port to use, and the directory - as well as any required credentials. If the correct information is provided, then Visual Studio 2005 reaches out to the remote server and creates the appropriate files for the start of your application, just as if it were doing the job locally. From this point on, you can open your project and connect to the remote server using FTP.
Web Site Requiring FrontPage Extensions
The last option in the Choose Location dialog is the Remote Site option (see Figure 19-7). Clicking this button provides a dialog that enables you to connect to a remote or local server that utilizes FrontPage Extensions.
Категории