You might have noticed that Visual Studio .NET scatters the files that make up an ASP.NET project into two different physical directories. The solution files with .sln and .suo extensions go in the default Visual Studio projects location, which is the C:\Doc uments and Settings\Administrator\My Documents\Visual Studio Projects folder (unless you ve changed it in the Projects and Solutions page of the Options dialog box that you reach from the Tools menu); .aspx, .vb, .vbproj, and other source code files go

Using Barcode generator for VS .NET Control to generate, create USS-93 image in .NET framework applications.

www.OnBarcode.com

You can get more control of which folders are used for your source files and keep the solution files in the same directory as the other files by manually creating a virtual directory for IIS before creating the project. Here s how to proceed: Create a blank solution from the New submenu of the File menu for example, a solu tion named AspNetDemoProject in the C:\root directory. Next, right-click on the new C:\AspNetDemoProject folder from inside Windows Explorer, select the Sharing com mand from the context menu, and then switch to the Web Sharing tab. (See the left por tion of Figure 24-4.) Click on the Share This Folder radio button, which displays the Edit Alias dialog box. (See the right portion of Figure 24-4.) If you want the virtual folder and the physical directory to have the same name, click the OK button once to close this window and a second time to close the Properties window. Go back to Visual Studio .NET and create a new Web Form project in this folder by typ ing the name of the virtual directory in the New Project dialog box:

Using Barcode creation for iPhone Control to generate, create GTIN - 128 image in iPhone applications.

www.OnBarcode.com

All the files of the project will be created in this folder. The only noteworthy limitation of this technique is that you can t reach the solution with the project from Web command in the Open submenu. This command can only see physical folders inside the c:\Inetpub\wwwroot directory.

Using Barcode printer for iPhone Control to generate, create Code39 image in iPhone applications.

www.OnBarcode.com

Creating a virtual directory for Internet Information Services

Part VI:

Internet Applications

Web Forms Dynamics

Let s consider in more detail what happens when a client browser interacts with a Web Forms application. You need this information to understand what you can do with Web Forms, as well as which actions are to be performed on the server and which ones on the client.

Code-Behind Classes

One of the major defects of classic ASP is the inability to separate the user interface (the HTML text) from the script code that does the actual page processing. This obsta cle prevents a clear separation between the job of the graphic designer and the job of the programmer, and most ASP developers become experts in user interface issues as well as programming, with overall results that are less than exciting in most cases. (That was the case with my results anyway.) Web Forms take a completely new approach that, while not perfect, is a big step in the right direction. When a browser posts a request to an .aspx file, the ASP.NET DLL intercepts the request, loads the file, and parses its @Page directive looking for the Inherits attribute. This attribute s value is the name of the class that contains the code associated with server-side events for that page for example, the event handlers that execute when a button is clicked. This class must be in a DLL that s stored in the /Bin subdirectory under the application s root directory. The association between event handlers and user interface elements is based on the id attributes of the interface elements. Interestingly, ASP.NET doesn t really load the original DLL. Instead, it copies the DLL to another location and then loads this copy, which is called the shadow copy. This oper ation slows the processing of the first request but has a great advantage: you can overwrite the original DLL without getting an error because IIS isn t locking it. When another request comes, ASP.NET checks that the shadow copy still matches the original DLL and performs the copy operation again if necessary to keep the two versions in sync. This shadow copying feature is a great improvement over the way classic ASP deals with compiled DLLs. As many ASP developers know, you have to restart the IIS application (and at times the entire IIS) to replace a compiled COM DLL that s being used by IIS.