Other Ways to Work with Web Data

 

Unlike earlier generations of applications, deploying Web applications in general, and ASP.NET applications specifically, does not require modifying the registry or installing Component Object Model (COM) components. However, you must still perform some administrative tasks to prepare your application to work on another machine.

Creating an Application in IIS

To process ASP.NET Web pages on the Web server through Internet Information Services (IIS), you must first create an application in IIS. To IIS, an application isn't just your Web code. It's a specific setting used to bring IIS internal operations into play over and above what would be required to serve simple HTML pages. To create an application in IIS, open Administrative Tools from Control Panel. From the list of administrative tools, open Internet Information Services Manager.

Note 

If you are using Microsoft Windows XP Professional, you might need to click Switch To Classic View in Control Panel to see the Administrative Tools option.

The dialog box should look as shown in Figure A-1.

image from book
Figure A-1: The IIS Manager dialog box

In the console tree on the left, click the + sign next to the name of your computer to expand the information related to the computer. Next, expand Web Sites, and then expand Default Web Site. The resulting view will look like Figure A-2, although you might have some additional branches in your file structure.

image from book
Figure A-2: The IIS Manager console tree with expanded file structure

The icons next to the folder names will vary from one operating system to another. However, any folder with a simple file folder icon is not set up as an application in IIS.

There is one minor problem with using IIS Manager. While you can easily convert an existing folder to an IIS application folder, there is not an obvious or convenient way to create a new folder in IIS Manager. By convention, folders in c:\inetpub\wwwroot (presuming c: is the system drive) appear in the tree view in IIS Manager. IIS applications can be placed anywhere in the file system, but it is generally easier to just create new applications in c:\inetpub\wwwroot.

To create a totally new application (folder and all) in IIS Manager, begin by right-clicking Default Web Site. On the menu that appears, click New, and then click New Virtual Folder. A wizard appears, and the first page should look like Figure A-3.

image from book
Figure A-3: The Virtual Directory Creation Wizard in IIS Manager

Click Next to see a page similar to Figure A-4.

image from book
Figure A-4: The Virtual Directory Alias page

This page of the wizard asks you to name the virtual folder. The name of the folder must follow the same naming conventions as directory names. When you enter a name, make sure you can remember it. In the next step, the wizard asks for the physical directory name for the virtual folder. Keep in mind that the virtual folder name ultimately forms part of the URL for your Web pages, so choose wisely. Click Next to see a page similar to Figure A-5.

image from book
Figure A-5: The Web Site Content Directory page

On this page, you can enter the folder name directly. If you are a terrible typist like me, or if you want to create a new folder, click Browse. The resulting dialog box is a standard folder selection dialog box. Locate the wwwroot folder (remember, it will be c:\inetpub\wwwroot if Windows is installed on the c: drive). The dialog box should look like Figure A-6.


Figure A-6: The Browse For Folder dialog box

Click Make New Folder, and a new folder is created for you to rename, as shown in Figure A-7.


Figure A-7: Creating a new folder in the wizard

Enter the same name that you used for the virtual folder. Click OK, and then click Next. The next page is the Access Permissions page, as shown in Figure A-8.

image from book
Figure A-8: The Access Permissions page

The default selection on this page is almost always adequate. The Run Scripts (such as ASP) option refers to classic ASP files, not ASP.NET. Because ASP.NET provides for compiled applications, you might think that you should select the Execute (such as ISAPI Applications Or CGI) check box, but you should not. ASP.NET is internally quite different from these technologies, so the default security should be adequate. Click Next. On the final page of the wizard, click Finish.

You should see the folder you created in the IIS Manager console tree, as shown in Figure A-9.

image from book
Figure A-9: IIS Manager with the new virtual application

The wizard allows you to set most of the options for the virtual folder, but not all of them. When you right-click the new folder and select Properties, the properties folder for the application appears as shown in Figure A-10.


Figure A-10: The IIS Manager virtual folder properties dialog box

It is here that you configure your virtual folder to become an IIS application if it's not already configured. If the Application Name text box is empty or disabled, the virtual directory is not configured as an IIS application. Simply click Create, and the application will be named and configured for you. If you were to close the properties dialog box now, you would see that the folder icon representing your virtual folder wasn't the typical yellow Windows folder icon, but rather a dark ball with a yellow "x" in an open box. This icon tells you that IIS has identified your virtual folder as an IIS application folder.

Before you close the properties dialog box, you might want to check some other things. For example, click Configuration on the Virtual Directory tab to open the Application Configuration dialog box, as shown in Figure A-11.


Figure A-11: The Application Configuration dialog box

The Mappings tab provides a list of file extensions, along with paths to the executables that will process files with each extension in the folder. Highlighting the .aspx extension and clicking Edit, for instance, allows you to see which executable will handle the .aspx extension. In user newsgroups, a common problem new users report is that none of their ASP.NET Web controls are rendered. If Web controls are not being rendered, a likely cause is that ASP.NET has not been installed, or the configuration for the folder is incorrect. You can explore the other tabs, and then click Cancel to exit the Application Configuration dialog box.

The ASP.NET tab allows you to control, among other things, which version of ASP.NET is used for the folder. In Figure A-12, I am using version 2.0.50215.0. If you have multiple versions of ASP.NET installed, you can select a version from the ASP.NET Version list.


Figure A-12: The ASP.NET tab in the virtual folder properties dialog box

On the Directory Security tab, click the first Edit button, and the dialog box shown in Figure A-13 appears.

image from book
Figure A-13: The Authentication Methods dialog box

The top section of the Authentication Methods dialog box allows you to determine whether anonymous access to the virtual directory is allowed. That is, if a user tries to enter the site, and the user is not logged in to a user account recognized by the Web server, should the user be allowed in? If you select the Anonymous Access check box, users who are not recognized will be allowed into the site and will take on the identity of the user specified, generally IUSR_<MachineName> (in this example, IUSR_DELL670). In Classic ASP, this user had to have rights to whatever resources your ASP application needed to access. In ASP.NET, things are a little more complicated, and authentication and authorization involve a mixture of settings in IIS and in the Web.config file. Anonymous access is almost always enabled for Internet Web Forms applications. In most cases, even intranet applications are configured to allow anonymous access.

Note 

The issue of identifying users who want to use your Web Forms application is covered in Chapter 7, along with login controls.

 


Programming Microsoft Web Forms
Programming Microsoft Web Forms (Pro Developer)
ISBN: 0735621799
EAN: 2147483647
Year: 2005
Pages: 70
Authors: Douglas J. Reilly
BUY ON AMAZON

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net