Search   Articles   Dev Forums   Personalize   Favorites   Member Login   ASP.Net Hosting
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Sunday, November 23, 2008

Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 
Server-Side Technologies For Providing Dynamic Content

    Each of these technologies relies on a modular attachment added onto the web server rather than the browser. Consequently, only HTML, and any client-side script, is sent back to the browser by the web server. In other words, none of the server-side code is sent back. Server-side technologies have a more consistent look and feel than client-side ones, and it doesn't take that much extra learning to move between some of the server-side technologies (excepting CGI).

CGI
    The Common Gateway Interface (CGI) is a mechanism for creating scripts on the server, which can then be used to create dynamic web applications. CGI is a module that is added to the web server. It has been around for quite a bit longer than even ASP, and right now, a large proportion of dynamically created web pages are created using CGI and a scripting language. However, it's incorrect to assume that CGI does the same job as ASP.NET or ASP. Rather, CGI allows the user to invoke another program (such as a Perl script) on the web server to create the dynamic web page, and the role of CGI is to pass the user supplied data to the this program for processing. However, it does provide the same end result – a dynamic web application.

You should be aware that CGI has some severe shortcomings:.

  • It is not easy for a beginner to learn how to program such modules.
  • CGI requires a lot of server resources, especially in a multiuser situation.
  • It adds an extra step to our server–side model of creating dynamic content: namely, it's necessary to run a CGI program to create the dynamic page, before the page is processed on the server.

What's more, the format in which CGI receives and transmits data means that the data is not easily manipulated by many programming languages, so you need one with good facilities for manipulating text and communicating with other software. The most able programming languages that can work on any operating system for doing this are C, C++ and Perl. While they can adequately do the job for us, they are some of the more complex languages to learn. Visual Basic doesn't offer adequate text handling facilities, and is therefore rarely used with CGI.

Despite this, CGI is still very popular with many big web sites, particularly those running on UNIX operating systems. It also runs on many different platforms, which will ensure its continued popularity.

ASP
    Active Server Pages (ASP) is now dubbed "Classic ASP" and if you see this term in the book, we will be using it to describe any ASP that isn't ASP.NET. ASP commonly relied on either of the JavaScript or VBScript scripting languages (although it was also possible to use any scripting language installed on Windows, such as PerlScript) to create dynamic web pages. ASP is a module (the asp.dll file) that you attach to your web server, and it then processes the JavaScript/VBScript on the web server, and turns it into HTML, before sending it into the server, rather than doing it on the browser.

ASP lets us use practically any of the functionality provided by Windows, such as database access, e-mailing, graphics, networking, and system functions, and all from within a typical ASP page. However, ASP's shortcomings are that it is very, very slow performance wise. It is also restricted to using only scripting languages. It can't do all the things that a fully-fledged programming language can. Secondly, the scripting languages, being like "junior" versions of full programming languages, took a lot of shortcuts to make the language smaller. Some of these shortcuts make their programs longer and more complicated than is otherwise necessary. As we're going to see, ASP.NET rectifies a lot of this by making code more structured, easier to understand, and shorter.

JSP
   JavaServer Pages (JSP) is a technology that allows you to combine markup (HTML or XML) with Java code to dynamically generate web pages. The JSP specification is implemented by several web servers, as opposed to ASP which is only supported under IIS, and plug-ins are available that allow you to use JSP with IIS 4.0/5.x. One of the main advantages of JSP is the portability of code between different servers. JSP is also very powerful, faster than ASP, and instantly familiar to Java programmers. It allows the Java program to leverage the aspects of the Java2 platform such as JavaBeans and the Java 2 libraries. JavaServer Pages isn't directly related ASP, but it does boast the ability to embed Java code into your web pages using server-side tags. More details can be found at the official site at http://www.javasoft.com/products/jsp/index.html and at the JSP FAQ at http://www.esperanto.org.nz/jsp/jspfaq.html.

ColdFusion
   ColdFusion (http://www.macromedia.com/software/coldfusion/) also enables servers to access data as the server builds an HTML page. ColdFusion is a module installed onto your web server. Like ASP, ColdFusion pages are readable by any browser. ColdFusion also utilizes a proprietary set of tags, which are processed by the ColdFusion Server software. This server software can run on multiple platforms, including IIS, Netscape Enterprise Server and Unix/Apache. The major difference is that while ASP.NET solutions are built primarily with programming languages and objects, ColdFusion utilizes HTML-like tags, which encapsulate functionality. A drawback is that the ColdFusion software doesn't come for free and indeed you could find yourself paying well in excess of a thousand dollars for the privilege of running Cold Fusion on your web server.

PHP
   PHP (originally Personal Home Pages, but more recently PHP HyperText Preprocessor) is another scripting language for creating dynamic web pages. When a visitor opens the page, the server processes the PHP commands and then sends the results to the visitor's browser, just as with ASP.NET or ColdFusion. Unlike ASP.NET or ColdFusion, however, PHP is open-source and cross-platform. PHP runs on Windows NT and many Unix versions, and it can be built as an Apache module and as a binary that can run as a CGI. When built as an Apache module, PHP is especially speedy. A downside is that you have to download PHP separately and go through a series of quite complex steps to install it and get it working on your machine. Also PHP's session management was non-existent until PHP 4, and still is even now,inferior to ASP's even now.

PHP's language syntax is similar to C and Perl. This might prove a barrier to people with no prior programming experience, but if you have a background in either language then you might want to take a look. PHP also has some rudimentary object-oriented features, providing a helpful way to organize and encapsulate your code. You can find more information about PHP at http://www.php.net.

ASP.NET
   So why are you telling me about all these other technologies if we're only going to be learning about ASP.NET you might be wondering? Hopefully you'll see a similarity between the technologies, and this will aid your understanding of ASP.NET.

ASP.NET also relies on a module attached to the web server. However, the ASP.NET module (which is a physical file called aspnet_isapi.dll) doesn't do all of the work itself; it passes some on to the .NET Framework to do the processing for it. Rather than going into ASP.NET in this subsection here, it's time to start talking about it as a separate entity in its own right, as this is the focus of the book.

What is ASP.NET?
   We're going to be asking this question a lot throughout the book, and each time we ask it, we're going to give you a slightly more in-depth answer. If we were we to give you a full answer now, you'd be overwhelmed by as-yet meaningless jargon. So, you'll probably be aware of some unanswered questions each time we describe it.

Our original definition, right at the very start of the chapter, was "ASP.NET is a new and powerful technology for creating dynamic web pages", and this still holds true. However, as you now know, it isn't the only way to deliver dynamic web pages, so let's refine our definition a little to read:

A new and powerful server-side technology for creating dynamic web pages.

Secondly, ASP.NET isn't the only thing that we're interested in. In fact, it's one of a set of technologies that comprise the Microsoft .NET Framework. For now, you can think of this as a giant toolkit for creating all sorts of applications, and in particular, for creating applications on the Web. When we come to install ASP.NET, we will also be installing the .NET Framework at the same time, and we'll be using bits and pieces of the .NET Framework throughout the book.

How does ASP.NET differ from ASP?
   Steady on! We're just getting to this part. ASP, as we've said is restricted to using scripting languages, mainly JavaScript or VBScript (although it can be any scripting language supported by the Windows system). We add ASP code to our pages in the same way as we do client-side script, and this leads to problems such as messy coding and restricted functionality. ASP.NET has no such problems.

First off ASP.NET allows you to use a far greater selection of full programming languages and also allows you to utilize to the full the rich potential of the .NET Framework. It helps you create faster, more reliable dynamic web pages with any of the programming languages supported by the .NET Framework. Typical languages supported natively are VB.NET, C# and a new version of JavaScript called JScript.NET. On top of this it is expected that third party developers will create versions of Perl, Python, and many others to work in ASP.NET. And no, before you ask, we don't expect you to be know any of these programming languages. We're going to choose one language, VB.NET, and teach you ASP.NET with it. We've chosen VB.NET as it's arguably the simplest for beginners, and it can do pretty much anything that the other languages we mentioned can as well. Lastly, and most importantly we've chosen VB.NET as it comes free with ASP.NET – so when you install ASP.NET you get VB.NET as well.

At this stage, you might be thinking, "Hang on, I've got to figure out VB.NET, then I've got to get a handle on ASP.NET – that sounds like an awful lot to learn." Don't worry; you won't be learning two languages. ASP.NET, as we said right from the beginning, is not a language – it is a technology. This technology is accessible, via a programming language. What we're going to be doing is teaching you ASP.NET features as we teach you VB.NET. So in other words, you will be creating your web pages using VB.NET and using ASP.NET to drive it. However, before you rush out and get a VB.NET book instead, we will be approaching the language from the angle of creating dynamic web pages only.

In summation, ASP.NET is a server-side technology that lets us use fully-fledged programming languages to create your web pages.

I'm still confused about ASP, ASP.NET, and VB.NET
   It's really important to get these terms separate and distinct in your mind, so before we move on to actually installing and running ASP.NET, we're going to go back and redefine them just to make sure:
  • ASP – a server-side technology for creating dynamic web pages that only lets you use scripting languages

  • ASP.NET – a server-side technology for creating dynamic web pages that lets you use any fully-fledged programming language supported by .NET

  • VB.NET – our chosen programming language for writing code in ASP.NET

Now it's time to get it all installed.

The Installation Process
    Installation is going to be done in three steps. We're going to install the web server first, next, we're going to install the prerequisites required for ASP.NET to work, and then, lastly, we're going to install ASP.NET Premium Edition or .NET Framework SDK (which also contains ASP.NET). SDK stands for Software Development Kit, and the only real difference with SDK's is the huge amounts of extra documentation and examples they supply.

Anybody who is familiar with ASP might be used to it being installed automatically with the web server, and thereby doing it all in one step. This is true – classic ASP is still installed with the web server, however ASP.NET currently is only available as a separate download. This means you will have to download ASP.NET from Microsoft's web site or from CD (if you have one). However, before you can install ASP.NET, it is necessary to have a working web server.

If you have installed IIS 5.x already, or have installed either the Windows 2000 Server or Advanced Server operating system, then the good news is that you can skip this section, and go straight onto the section about installing the .NET Framework. However for the rest of us, you will have to pay careful attention to the next section.

Installing the IIS 5.x Web Server
   We'll look at the installation process for IIS on Windows 2000 Professional and Windows XP Professional together, as they don't differ significantly. The main difference is that Windows 2000 installs IIS 5.0, while Windows XP installs IIS 5.1. The options for installing are exactly the same, the only thing that might differ is the look of the dialog boxes. However, the options you need to select are still the same.

Before you install it though, it's worth noting that we might not have to do much in this initial stage, as it's possible you're already running IIS 5.x. We'll describe a process for checking whether this is the case as part of the installation process. You should also note that to install anything (not just ASP.NET, but literally anything) on Windows 2000/XP you need to be logged in as a user with administrative rights. If you're uncertain of how to do this, we suggest you consult your Windows documentation. Right let's get started!

Try It Out – Locating and/or installing IIS 5.x on my Web Server machine
  1. Go to the control panel (Start | Settings | Control Panel) and select the Add/Remove Programs icon. The following dialog will appear, displaying a list of your currently installed programs:

  2. Select the Add/Remove Windows Components icon on the left side of the dialog, to get to the screen that allows you to install new windows components:

  3. Locate the Internet Information Services (IIS) entry in the dialog, and note the checkbox that appears to its left. Unless you installed Windows 2000 via a custom install and specifically requested IIS, it's most likely that the checkbox will be unchecked (as shown above).

  4. If the checkbox is cleared, then check the checkbox and click on Next to load Internet Information Services 5.x. You might be prompted to place your Windows 2000/XP installation disk into our CD-ROM drive. It will take a few minutes to complete. Then go to Step 5.

    OR

    If the checkbox is checked then you won't need to install the IIS 5.x component – it's already present on your machine. Go to Step 6 instead.

  5. Click on the Details button – this will take you to the dialog shown below. There are a few options here, for the installation of various optional bits of functionality. For example, if the World Wide Web Server option is checked then our IIS installation will be able to serve and manage web pages and applications. If you're planning to use FrontPage 2000 or Visual InterDev to write your web page code, then you'll need to ensure that the FrontPage 2000 Server Extensions checkbox is checked. The Internet Information Services Snap-In is also very desirable, as you'll see later in the chapter, so ensure that this is checked too:

    For the purpose of this installation, make sure all the checkboxes in this dialog are checked; then click on OK to return to the previous dialog.

  6. There's one other component that we'll need to install, for use later in this book – it's the Script Debugger. If you scroll to the foot of the Windows Components Wizard dialog that we showed above, you'll find a checkbox for Script Debugger. If it isn't already checked, check it now and click on Next to complete the installation. Otherwise, if both IIS 5.x and the script debugger are already present, you can click on Cancel to abort the process:

How It Works
    Web Services starts up automatically as soon as your installation is complete, and thereafter, whenever you boot up Windows – so you don't need to run any further startup programs, or click on any short-cuts as you would to start up Word or Excel.

IIS installs most of its bits and pieces on your hard drive, under the \WinNT\system32\inetsrv directory; however, more interesting to us at the moment is the \InetPub directory that is also created at this time. This directory contains subdirectories that will provide the home for the web page files that we create.

If you expand the InetPub directory, you'll find that it contains several subdirectories:

  • \iissamples\homepage contains some example classic ASP pages

  • \iissamples\sdk contains a set of subdirectories that hold classic ASP pages which demonstrate the various classic ASP objects and components.

  • \scripts is an empty directory, where ASP.NET programs can be stored.

  • \webpub is also empty. This is a 'special' virtual directory, used for publishing files via the Publish wizard. Note that this directory only exists if you are using Windows 2000 Professional Edition.

  • \wwwroot is the top of the tree for your web site (or web sites). This should be your default web directory. It also contains a number of subdirectories, which contain various bits and pieces of IIS. This directory is generally used to contain subdirectories which hold the pages that make up our web site – although, in fact, there's no reason why you can't store your pages elsewhere. We'll be discussing the relationship between physical and virtual directories later in this chapter.

  • \ftproot, \mailroot and \nntproot should form the top of the tree for any sites that use FTP, mail, or news services, if installed.

  • In some versions of Windows , you will find an \AdminScripts folder which contains various VBScript files for performing some common "housekeeping" tasks on the web server, allowing you to stop and start services.

Working with IIS
    Having installed IIS web server software onto our machine, we'll need some means of administering its contents and settings. In this section, we'll meet the user interface that is provided by IIS 5.x.

In fact, some versions of IIS 5.x provide two user interfaces the MMC, and the PWS interface. We're only going to look at one, as the other version is now obsolete. The version we will use is the Microsoft Management Console (MMC) that is a generic way of managing all sorts of services. Let's take a quick look at it now.


<<<<.....back Next .....>>>>
DevASP.Net - Disclaimer - Privacy
Copyright © 2008 DevASP.net