CPAN 660 ASP.NET

Lecture #1:Introduction to ASP.NET

Introduction

ASP.NET is server side technology for creating dynamic web pages. It was developed based on tow separate technologies: ASP and .NET. With ASP.NET , web application can be created using any .NET supported language. In this course we will focus on creating ASP.NET web applications using VB.

.NET framework is the heart of .NET technology. It manages and executes applications and web services. .NET framework provides a rich set of class library called FCL ( framework class library). These classes are grouped using the concept of namespaces. The .NET technology is platform independent. Instead of compiling the .NET applications into machine language directly, they are compiled into MSIL ( Microsoft Intermediate Language) by the CLR ( common language runtime). The Just in Time (JIT) compiles the MSIL into machine specific code. .NET is also language independent. You can develop your application using one or a combination of .NET supported languages. ASP.NET has many enhanced features such as native XML support, easier database access, better performance, enhanced security and Enhanced state management.

Web applications run under the control of a web server. A web server is software that manages web pages and makes them available to clients over the internet. The web pages can be static, or dynamic. Dynamic web pages can be create either on the client using a script language, such as JavaScript, or on the server by a certain applications. ASP.NET rule comes to play in the process of generating dynamic content on the server side.

In order to work with ASP.NET, you need the following to be installed on your machine:

·  IIS installation with Script Debugger support

·  MDAC Microsoft Data Access components ( version 2.7 or later). MDAC enable .NET applications to communicate with databases. It can be downloaded from http://www.microsoft.com/data

·  .NET Framework: Can be downloaded from http://www.asp.net

Notice that when .NET framework is installed it registers itself under IIS. Any file with the extension aspx will be handled by the module aspnet_isapi.dll .If you have IIS installed after .NET Framework, you need to use the tool aspnet_regiis.exe. To do that, issue the following command at the command prompt

C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\> aspnet_regiis.exe –r

Then you can either use Visual Studio .NET to create and develop your applications, or you can simply use a text editor.

As an alternative, you can download Web Matrix from http://www.asp.net. This tool provides a similar IDE to Visual Studio . NET, further more, it comes with it’s own web server. So you do not need IIS installed to work with Web Matrix. However, you still need MDAC and .NET Framework installed first.

Managing IIS:

You can manage IIS either using Internet Service Manager or Microsoft Management Console.

You can find Internet Service Manager under Administrative Tools:

To use Microsoft Management Console (MMC) perform the following steps:

·  Select Run from Start menu and type mmc as shown below:

·  From the window titled Console1 select Add/Remove Snap-in…:

·  From Add/Remove Snap-in dialog click Add.. button to Console Root:

·  Select Internet Information Services from Add Standalone Snap-in dialog:

·  Click Add then Close buttons.

·  Click OK button

A new IIS snap-in is added to the Console Root window of MMC as shown below:

Creating Virtual Directory under Default Web Site of IIS:

IIS can access certain directories called virtual directories. The virtual directory is a pointer to a physical directory on you file system. In the following steps we will create a virtual directory called cpan660:

·  Create the folder c:/cpan660

·  Create a simple html file called test.html and store it under cpan660.

·  Open IIS manager, right click Default Web Site, and select New->Virtual Directory from the popup menu:

Virtual Directory Creation Wizard dialog appears. Click Next button.

·  Enter cpan660 as the alias name for the virtual directory:

·  Locate the physical directory for c:/cpan660:

·  Check the proper permissions as show below and click Next button:

·  click Finish button to complete this task.

Now you can browse the content of cpan660 by typing http://localhost/cpan660

In the browser address:

You can also change the properties of the cpan660 virtual directory. Select cpan660, right click, and select properties from the popup menu. The virtual Directory tab enable us to change the directory access, location and permissions.

Notice that checking the Directory browsing enabled us to browse through cpan660 folder. For security reasons, it is recommended that you disable this option when you deploy your application.

The Document tab enables us to determine the name and type of documents IIS will serve by default. IIS will search for these documents one by one and serve the first one it finds.

Managing multiple users accounts under IIS:

To create a virtual site for a specific user .perform the following steps:

·  Add this user and assign him/her a password. I will call this user cpan660user.

·  Create a folder called cpan660user under C:\Inetpub\ftproot then create a folder called public_html under cpan660user folder:

·  Create a simple HTML file and store it under public_html. Your folder should look as follows:

·  Right click Default FTP Site and select New ->Virtual Directory from the popup menu:

·  Type cpan660user in the Alias text field of the Virtual Directory Creation Wizard dialog and click Next button:

·  Enter C:\Inetpub\ftproot\cpan660user\public_html in the Path text field of the Virtual Directory Creation Wizard dialog and click Next button:

·  In the next step check Read and Write permissions and click Next button:

·  click Finish button to complete this task. You should see a new virtual site called cpan660user added to the Default FTP site as shown below:

If you want to change the permission or security setup , right click abdullah folder and select Properties from the popup menu:

The user cpan660user can use any FTP tool to upload and download files to his/her virtual site:

The last thing to do is to create a virtual director called cpan660user under Default Web Site. This enable IIS to serve documents and execute programs for the user cpan660user, To do that, follow the steps for creating virtual directories outlined above. Just make sure to map the virtual directory to C:\Inetpub\ftproot\cpan660user\public_html. To test the new virtual site for cpan660user , open your browser and type http://localhost/cpan660user in the browser address box. It should look as follows:

Note: you need to change the ownership of cpan660user folder to the user cpan660user, and the ownership of public_html to the user cpan660user and everyone.

3