Microsoft internet information server is a network file and application server and is included with windows NT server. IIS supports Hypertext transfer protocol (HTTP), files transfer protocol (FTP) and gopher information protocols.
An ISS (Internet Information Server) application is a Visual Basic application that lives on a web server and responds to request from the browser. An IIS application uses HTML to present its user interface and uses compiled Visual Basic to process requests and response to events in the browser.
To the user, and IIS application appears to be mode up of a series of HTML pages. To the developer, an IIS application is mode up of a special type of object called a web class, that in turn contains a series of resources called web items. The web class acts as the central functional unit of the application, processing data from the browser and sending information to the users. You define a series of procedures that determine how the web class responds to these request. The web times are the HTML pages and other data the web class can send to the browser in response to a request.
Introduction to IIS & ASP
As developing DHTML documents are eased in Visual Basic through DHTML application project type, developing ASP documents are also eased in Visual Basic through IIS application project type. This section explain about IIS application project type and shows how to use it.
Web classes
A web class a Visual Basic component that resides on a web server and responds t input from the browse. When an IIS application project type is opened, Visual Basic opens a web designer that creates the web class. Web classes typically contain web item (HTML files) and code that deliver those webitems to a client.
A web class in an IIS application has an associated .asp (Active server pages) file that Visual Basic generates automatically during the compile process. The .asp file hosts the web class on the web server and launches its scripts for execution.
Figure: Relationship between Webclass and ASP file.
As shown in the figure, each webclass has its own SP. In turn, a webclass can have many webitems (HRML files) associated with it.
Advantage of IIS application
- Reduced cost of deployment per user. End users of an IIS application can run the application using only a browser; no special software needs to be installed on their computers for the application to work.
- A familiar development environment and model for Visual Basic programmer
- Access to a broad audience. IIS applications work with a wide variety of browsers and operating systems, so it can easily reach a side audience.
- It can send HTML pages either from templates or from code to the browser.
Note: templates are nothing but webitems that holds designed HTML pages. A temple can |
have only one HTML page.
In the chapter the discussion will go on application of IIS, ASP and DHTML then Debugging the IIS application and development process.
IIS applications VS. ASP Application
IIS applications bear a superficial resemblance to Active server page4s applications. Both types of application present dynamic websites and perform their processing on the server rather than the client. However, each ahs its unique advantages. Active Server pages are for script developers interested in authoring web pages, and offer the unique capability of intermingling script with HTML IIS applications are for Visual Basic developers building web based applications, rather than web pages. IIS application allow for complicated business processing and easy access from almost any browser or platform.
IIS application VS > DHTML applications
IIS applications are similar to DHTML applications in one way. Both arrange the contents of web document dynamically. However, there are some key differences between the two types of applications:
- Dependency – DHTML applications are dependent on internet explorer 4.0 or later. But end users of an IIS application do not need a specific operating system or browser.
- Location of processing – IIS applications are designed to perform most of their processing on the web server, but DHTML applications perform most of their processing on the browser machine.
Webclass designer
When a project of types IIS application is opened, Visual Basic presents webclass designer as in Figure:
Figure: Webclass designer.
The treeview panel displays each webitem and connected event in the webclass. There are two kinds or webitems:
- HTML template webitems – HTML files that can be sent to the browser in response to a request
- Custom webitems – programmatic resources that creates HTML files on the fly.
The detail panel displayed information about the currently selected item in the treeview panel.
IIS application Development process
The process of creating an IIS application is similar to creating any other project in Visual Basic. The overall processes presented below.
The overall process for creating IIS application is:
- Start a new project and select IIS application as the project type.
- Save the project
Note: Unlike forms based Visual Basic applications, you must save an IIS application before |
you add HTML template web items to it
- Add as many HTML temple webitems and custom webitems to the webclass needed.
- Add any custom events to the project
- Write code for all standard, template, and custom events in the project.
Note: make sure you write code for the start event, or your application will not run unless the |
user specifies a webitem in the base URL for more information see “Setting The start Event”
- Add other code modules or web class objects to the project.
- Test and debug the application by running the project and viewing the application in the browser. It is recommended that you test all browsers you plan to support before releasing the application to end users.
- Complete the project
- Deploy the application
Examples
This section shows how to create an ASP file using Visual Basic IIS application project type. Before creating the IIS application create an HTML file secret.htm whose code listing is given below.
<HTML
<BODY>
<CENTER>
<H2><U> now you are in the secreat site </U><H2>
</CENTER>
</H2>
</BODY>
</HTML>
This file will be used as a webitem in the IIS application project.
Creating a new IIS project
- Choose File |new project to open the new project dialog box
- Double click the IIS application icon to create an IIS application project
- Name the project a SIISPro
- In the project window double click the webclass1 to bring its designer front
- Set the properties of the webclass1 as given below:
Property Value Description
Name wclsSecret specifies the name of the webclass
Name in URL key secret specifies the name of the web class as it appears
in the address that invoke the webclass. That is,
its corresponding asp page will be created as
key secret. Asp (key to secret) which is used in
the address string.
- Save the project with the default names. (it is very important to store the project in a spedific folder. Then alone the HTML files that are address as webitems can be stored in the project folder).
- Right click on the HTML template webitems in the Treeview panel and choose add HTML template from the pop up menu that appears.
- In the dialog box that appears browse and select secret.Htm and click open. This will add a template under the HTML template webitems in the treeview panel as templae1. rename it as secret htm.
- Open the code window of the web class designer
- Replace the code of the web class start event procedure [webclass_start ()] with the following code.
Private sub Class_start ()
Dim param
Set param = Request.Quary string
If param (“name”) = “Indian” then
‘rendering the secret site
secretHtm. Write template
Else
‘Writing a reply to the user
With Response
.Write “<html>”
.Write “<body>”
.Write “You are not an authorized user to go to_ the secret site”
.Write”</body>”
.write”</html>”
End with
End if
End sub
This event will occur when the key Secret .ASP invoke this web class. This procedure checks whether visitor is an authorized user or not. It he is an authorized user, it sends the contents of the template file to the browser using the write Template method. Otherwise it creates an HTML page, which indicates that he is not an authorized user, and sends it to the browser.
- Choose File | Make IIS pro.dll to compile the project. Visual Basic will create key secret.ASP file.
- Create an HTML HTM.htm file whose code listing is given below. This file will call the key secret.ASP file.
<HTML>
<BODY>
Type your name and click submit <BR>
To go to the secret site.
<BR><BR>
<FORM method =”Get”
Action = http://127.0.0.1/ASP/keysecret.ASP>
<INPUT type = text Name =”Name”><BR><BR>
<INPUT type = submit = “submit” value=Submit>
</FROM>
</BODY>
</HTML>
The string /ASP specifies the virtual directory which is mapped to the project directory in which the key secret .ASP file is stored.
- Type Indian in the text field and click the submit button. This will call the key secret. ASP file, which invokes the web class. The web class verifies the entered name. as it is Indian (the valid name), it will supply the secret.htm file, which is stored in the secret Htm template. The browser receives this file and renders it as in Figure:
Figure: HTML pages sent by the ASP file when the user is an authorized person.
Is some other name is typed and the submit button is clicked, the web class crates HTML page on the fly indicating that the user is not an authorized user and sends it to the browser. The browser renders it an in Figure.
Figure – HTML created and page sent by the ASP file when the user is not an authorized person.
Debugging your IIS application
You debug an IIS application in the same way you do any other Visual Basic application-by entering run mode from Visual Basic. Visual Basic loads the webclass run time, creates the virtual root form which to run the .asp file for the application, if necessary, and launches the system’s default browser with an HTTP reference to the .asp file, the .asp file, in turn, launches the webclass.
Note although you can view the hen files associated with your application in the browser by opening them from the browser’s file menu, this is not debugging your application. You must use the start option from Visual Basic to enter debugging mode.
When the debug, you have the full Visual Basic development environment at your disposal. You can use all the tools available in Visual Basic break points, watch variables, debug statement, and so on to debug your project.
Visual Basic prompts you when you debug that it is going to create a virtual directory for your project. A virtual directory is a directory outside you web server’s home directory that appears to browsers as a subdirectory of the home directory. Allows you to publish contents to the web from directories outside the home directory structure. You cannot change the location of the Virtual directory Visual Basic creates for the webclass.
The project properties dialog box’s debugging panel settings determine whether the system waits for you to tell it what to do when you go into run mode or automatically starts the webclass you specify. When you chose to automatically start the webclass, Visual Basic launches Internet Explorer, navigates to the URL for you application, and fires the webclass Begin Request event.
Visual Basic deletes all temporary files when it comes out of run mode. In addition, it destroys the instance of the webclass designer and restarts the designer in design mode.
Error in webclasses
You can use Visual Basic error-handling features in you ISS applications to trap errors and take corrective action. When an error occurs, Visual Basic sets the various properties of the error object, Err, such as an error number or a description. You can use the Err object and its prop0erties in an error-handling routine so that you application can respond intelligently to an error situation.
In addition to standard error handling, IIS applications allow you to use two special features to handle errors:
- You can use the Trace method to debug your application of the production computer.
- You can use the Fatal Error Response event to respond to serious run time errors.
Using the trace method
You can use the trace method to help identify errors during the debug process and to track performance and statistical data. The trace method sends a specified string to the win 32 output Debug String API. The string can then be captured to a suitable debugging tool such as DBMON.
Using the trace method can allow you to debug on your production server computer and record useful information such as information you need.
Handling fatal errors
A fatal error on a webclass is one from which the application cannot recover or restore the appropriate webitem. For example, a fatal error might be an unhandled error within a webclass event, a structural error, or an unexpected error within the runtime DLL. Following such an error, the webclass run time fires the fatal response event. The application is terminated and the instance of the webclass is destroyed.
When a fatal error occurs, the application can write a message to the response object in the handler for the Fatal Error Response event. This message can be one that you write, or it can be the default message for the .asp file associated with the webclass. To write your own message, use the response object, then set the send default argument of the fatal error response event to false. To use the default error message, leave the send default argument set to true.
Note: the webclass run time provides an error property that is only available from within the |
fatal error response event. This property returns an object that describes the error that caused
the webclass to terminate.
The webclass run time also logs fatal errors to the NT event log. On Windows 95 systems, the run time DLL creates a log file in the windows directory and logs the error there.