Introduction to ASP.NET 2.0

What is ASP.NET 2.0
Internet Information Services (IIS)
Installation of ASP.NET 2.0 (and Optionally Visual Web Developer)
Local IIS Web Sites
Creating Virtual Directories in IIS
Configure ASP.NET Applications for an ASP.NET Version
Configuring Permissions

 

What is ASP.NET 2.0

ASP.NET is a programming model for building Web-based applications. It is essentially a runtime and set of .NET Framework class libraries that can be used to build dynamic Web pages. It runs within the context of a Web server, such as Microsoft Internet Information Server (IIS), and processes programming instructions on the server to service browser requests. Unlike static HTML, which is served directly from the Web server, ASP.NET pages are actually executed on the server to produce dynamic results. The final rendering of a page might be constructed from a variety of different instructions and/or data sources.

ASP.NET pages are stored under the .aspx extension. Pages are created by a programmer as a combination of text, markup (such as HTML), and ASP.NET server-specific tags and script, and then stored on the Web server. You can think of a stored ASP.NET page as a set of instructions for how to build an HTML page. When the page is requested, the server-side logic is processed to create a page in pure markup that the client browser can understand and render. Because the rendered output is pure markup, any browser can read it; all the dynamic processing happens on the Web server. ASP.NET server-specific tags are very powerful, including the capability to react to user actions, connect to data stores, and automatically build very complex HTML structures.

As previously mentioned, ASP.NET is simply part of the .NET Framework and, consequently, ASP.NET pages can take advantage of all of the services offered by that framework, including networking, data access, security, and much more. The fact that all of these framework services are available to ASP.NET enables you to build much richer Web applications than ever before. You can spend less time reinventing the basic building blocks that all applications need, and spend more time focusing on the specific logic that is unique to your application.

ASP.NET also introduces some unique innovations in Web programming that greatly improve the development model over classic Active Server Pages (ASP).

ASP.NET 2.0 further increases developer productivity with performance, reliability, and deployment. ASP.NET 2.0 has a specific set of server controls for programmers to add data interactions to a page. The data-specific controls are divided into two groups: data source controls and data-bound controls. Data source controls create the link to the database. The data-bound controls take the information from the data source controls and create a rendering on the page.

For more information on ASP.NET 2.0, please visit The Official Microsoft ASP.NET 2.0 Site.

 

Internet Information Services (IIS)

To run ASP.NET 2.0 on your computer you will need the Internet Information Services (IIS) component installed on your machine.

IIS 6.0 is included with Windows Server 2003 and is installable via the Add or Remove Programs item in the Control Panel. IIS 6.0 installs in a highly secure state, serving only static HTML content until other features and file types (such as ASP and ISAPI) are enabled.

IIS 5.1 comes with Windows XP Professional and is installable via the Add or Remove Programs item in the Control Panel.

IIS 5.0 comes with Windows 2000 Server and is installed by default. It also comes with Windows 2000 Professional and is installable via the Add or Remove Programs item in the Control Panel.

Note: IIS 4.0 and Personal Web Server (PWS) do NOT support ASP.NET.

Following are the instructions to install IIS component on a Windows XP Professional machine:

1. Place the Windows XP Professional CD-Rom into your Optical Drive.

2. Open Add/Remove Windows Components found in Add/Remove Programs in the Control Panel.

3. Check Internet Information Services (IIS) checkbox and click Next.

4. Once the installation is completed, you can view your homepage by typing "http://localhost/" into the address bar of your browser.

5. The default web directory to place the web site is in 'C:\Inetpub\wwwroot', but you can always set up your own virtual directory through the IIS Manager. For more information, see Creating Virtual Directories in IIS below.

 

Installation of ASP.NET 2.0 (and Optionally Visual Web Developer)

The Microsoft .NET Framework version 2.0 redistributable package is the most recent update to the Microsoft .NET Framework and includes everything you need to run applications developed using the .NET Framework. This package only is sufficient to run ASP.NET 2.0 applications. However, it is recommended that you download the SDK because it includes the documentation.   

The Microsoft .NET Framework Software Development Kit (SDK) version 2.0 includes everything developers need to write, build, test, and deploy .NET Framework applications—documentation, samples, and command-line tools and compilers. You must install the .NET Framework Redistributable Package version 2.0 prior to installing the .NET Framework 2.0 SDK.

Download Microsoft .NET Framework 2.0

Visual Web Developer 2005 Express Edition is a lightweight, easy-to-use and easy-to-learn development tool focused exclusively on Web development. Inside, you will find everything you need to begin building exciting, dynamic Web applications with ASP.NET 2.0. It provides visual designers that make creating Web applications easy via an easy-to-use drag-and-drop interface and powerful code editor with rich functionality such as IntelliSense that makes writing code and HTML faster.

Download Visual Web Developer Express

 

Local IIS Web Sites

A local Internet Information Services (IIS) Web site is an IIS Web application on your computer. Creating or opening a local IIS Web site is useful in the following situations:

  • You want to test your Web site using IIS, which closely emulates how the Web site will run on a production server. This can have advantages over working with file system Web sites that run using the ASP.NET Development Server, because paths are resolved as they will be on a production server.

  • You already have a set of Web site files in a folder and you want to test the Web site with IIS. In this case, you can create a virtual directory in your local version of IIS.

  • Your local computer is also your Web server.

Requirements
To create a local IIS Web site requires the following:

  • Your computer must have at least IIS version 5.0 installed and running.

  • Your computer must be running the .NET Framework version 2.0.

  • ASP.NET version 2.0 must be enabled in IIS version 6.0. To enable ASP.NET by using IIS Manager, expand the local computer, and then click Web Service Extensions. In the details pane, click ASP.NET, and then click Allow.

  • You must be logged in as a user with administrative privileges. This is required because working with the IIS metabase (where information about IIS applications is stored) requires administrative privileges.

To open an existing local IIS Web site, the preceding must be true as well as the following:

  • The site to be opened must be configured as an IIS application. For more information, see Creating Virtual Directories in IIS below.

  • The site must be configured to use ASP.NET version 2.0. This is distinct from having ASP.NET 2.0 installed on the computer. It is possible to have ASP.NET 2.0 installed on the computer but have the site to be opened still mapped to use an earlier version of ASP.NET. For details, see Configure ASP.NET Applications for an ASP.NET Version below.

Note: You can create an IIS application as a subfolder of any existing IIS folder.

Running Local IIS Web Sites
When you run a local IIS Web site to test it, launches a browser and runs the Web site using the server name localhost. For example, if you have created the Web site ExampleSite, when you test it, go to the following URL:
http://localhost/ExampleSite/
IIS resolves the application name, whether it points to a folder that is under the IIS root or to another location, and serves pages from that folder.

Deploying Local IIS Web Sites
Local IIS Web sites are generally used only for development, so that individual developers can create and test ASP.NET Web pages on their own computers. In most cases, you must deploy the files from a file system Web site to a production server that is running IIS.

 

Creating Virtual Directories in IIS

In most cases, the content you publish to your Web or FTP site is located in a root or home directory on your computer, such as C:\Inetpub\wwwroot\. However, there might be instances when the content is located somewhere else, or even on a remote computer.

To publish from any directory not contained within your home or root directory, you can create a virtual directory. A virtual directory is a directory that is not contained in the home directory but appears to client browsers as though it were.

You can create a virtual directory through IIS Manager or by using Windows Explorer.

Important: You must be a member of the Administrators group on the local computer to perform the following procedures.

To create a virtual directory by using IIS Manager

  1. In IIS Manager, expand the local computer, expand the Web Sites folder, right-click the site or folder within which you want to create the virtual directory, point to New, and then click Virtual Directory. The Virtual Directory Creation Wizard appears.



  2. Click Next.

  3. In the Alias box, type a name for the virtual directory. (Choose a short name that is easy to type because the user types this name.)



  4. Click Next.

  5. In the Path box, type or browse to the physical directory in which the virtual directory resides, and then click Next.

    Note: This path is the root of your ASP.NET Web application.



  6. Under Allow the following permissions, select the check boxes for the access permissions you want to assign to your users, you must select Read and Run scripts, and then click Next.

    Note: The IIS Manager UI only configures settings at the IIS scope, so the the "Read", "Write", "Script source access", and "Directory browsing" check boxes only affect IIS-level behavior. These access controls in IIS have nothing to do with allowing/denying writing to an Access database or uploads, so enabling "Read" while disabling "Write", "Script source access", and "Directory browsing" definitely do nothing as far as denying writing to an Access database or uploads is concerned. Also see Configuring Permissions below.




  7. Click Finish. The virtual directory is created below the currently selected folder level. Right-click the Virtual Directory and then click Properties.

  8. Click the ASP.NET tab and choose ASP.NET 2.0 as ASP.NET version. Current version of ASP.NET 2.0 is 2.0.50727.

To create a virtual directory by using Windows Explorer

  1. Open Windows Explorer.

  2. Right-click the folder you want to be a virtual directory, and click Sharing and Security.

    Note: This folder will be the root of your ASP.NET Web application.

  3. Click the Web Sharing tab.



  4. Click Share this folder.

  5. In the Alias box, type the name for the virtual directory.

  6. Click OK twice.

Note: You can not change the ASP.NET version by using Windows Explorer.

 

Configure ASP.NET Applications for an ASP.NET Version

If you have different versions of .NET Framework installed on your computer, you may come across error when you run the ASP.NET application. For example, IIS may use .NET Framework 1.1 to compile your ASP.NET 2.0 pages. To fix this problem, you need to set the correct the .NET Framework version using IIS Manager as described above.

Alternatively, there is a little utility called ASP.NET Version Switcher which can quickly switch between different .NET versions that the ASPX pages are compiled against..

 

Configuring Permissions

An important aspect of working with an Access .mdb file and file upload to a folder on the Web server is to correctly configure permissions.

When a Web application uses an Access database, the application must have Read permission to the .mdb file so the application can access the data. Additionally, the application must have Write permission to the folder that contains the .mdb file. Write permission is required because Access creates an additional file that has the extension .ldb in which it maintains information about database locks for concurrent users. The .ldb file is created at run time.

By default, ASP.NET Web applications run in the context of a local machine account named ASPNET (for Windows 2000 and Windows XP) or in the context of the account NETWORK SERVICE (for Windows Server 2003). For example, for Windows 2000 or Windows XP Professional, if the Web server is named ABCServer, ASP.NET applications on the ABCServer computer run in the context of the local account ABCServer\ASPNET. Therefore, to use an Access database in an ASP.NET Web application, you must configure the folder that contains the Access database to have both Read and Write permissions for the local ASPNET user account.

If you create a Web site in Visual Web Developer, Visual Web Developer creates a folder named App_Data below the current root folder. The folder is designed to be a store for application data, including Access databases. The App_Data folder is also used by ASP.NET to store databases that the system maintains, such as the database for membership and roles. When Visual Web Developer creates the App_Data folder, it grants Read and Write permissions for the folder to the ASPNET or NETWORK SERVICE user account.

Note: As a security measure, files in the App_Data folder are not served by the Web server. Do not store any Web pages in the App_Data folder, because users will see an error if they request a page from that folder.

ASP.NET Maker 2 also creates the App_Data folder but you may need to set the permissions yourself. To set permissions in the App_Data folder,

  1. In Windows Explorer, move to the root folder for the Web site. e.g. C:\Inetpub\wwwroot\ExampleSite.
  2. If the App_Data folder does not already exist, create one.
  3. Right-click the App_Data folder, click Properties, and then click the Security tab.

  4. Under Group or user names, look for either of these user accounts:
    • If the computer is running Windows XP Professional or Windows 2000, look for computer\ASPNET.
    • If the computer is running Windows Server 2003, look for NETWORK SERVICE.
  5. Verify that the account has Read and Write permissions for the App_Data folder.

Similarly, set permissions in the folder where the uploaded file reside.

 

Note: If you use hosting, the hosting provider usually will provide a web based control panel for you to set the root of your ASP.NET applications, user permissions, and ASP.NET version. Some hosting provider may create a special anonymous user for your site.

 

 

 ©2004-2007 e.World Technology Ltd. All rights reserved.