HOWTO: Build an IIS Application and References

ID: Q191039


The information in this article applies to:
  • Microsoft Visual Basic Professional and Enterprise Editions for Windows, version 6.0


SUMMARY

Building your first IIS application can have some minor pitfalls. This article describes a simple IIS application to get you going.


MORE INFORMATION

Steps to Build a Simple IIS Application

  1. From the File menu, select New Project, and then select IIS application.


  2. Give your project a name and save the project. You cannot import a HTML file without saving the project first.


  3. From the WebClass designer window,, select the toolbar item Add HTML Template Webitem, and then select an HTML file to add to your project.

    NOTE: If you choose a xxx.htm in the working directory of your project, the WebClass designer makes a copy of the xxx.htm and renames it xxx1.htm in the working directory of your project. xxx1.htm is the HTML file the WebClass designer will be making changes to, not the xxx.htm: WebClass designer does not need the xxx.htm file. But, if you choose a xxx.htm not in the working directory of your project, it will make a copy in the working directory of your project and not change the name from xxx.htm.


  4. By default, this HTML Template Webitem will be called Template1 in the WebClass designer window.


  5. View the Private Sub WebClass_Start(). It has code to display a default browser page. Comment out this code or delete it so the Start event looks like the following:
    
          Private Sub WebClass_Start()
             Set NextItem = Template1
          end Sub
     
    NextItem is used to shift processing from one WebItem to another during a single request. Using the NextItem will cause the Private Sub Template1_Respond() to fire.


  6. Here is a sample Private Sub Template1_Respond():
    
          Private Sub Template1_Respond()
              Template1.WriteTemplate
          End Sub
     
    The Template1.WriteTemplate will send the contents of Template1 to client browser window. Remember that Template1 is the HTML file you imported into the IIS application. If you don't put anything in this event and you run the project, the browser will come up with a blank page. You should do a dry run of this process to see how it works.


  7. Hit the F5 key to run the project. The WebClass designer will prompt you with a default Virtual directory that it is going to create in which to run the WebClass.


  8. The page you created should have come up in the browser. Now change some code to experiment:
    
       Private Sub Template1_Respond()
       'Write a reply to the user
         With Response
            .Write "<html>"
            .Write "<body>"
            .Write "<h1>WebClass1's Starting Page</h1>"
            .Write "<p>Response was created in the Template1_Respond event</p>"
            .Write "</body>"
            .Write "</html>"
        End With
       End Sub 


  9. Press the F5 key to run the project.


  10. Set the project Properties options for optimal performance: Retain In Memory, Unattended Execution, and Apartment Threaded.

    For additional information on these settings and other possible issues, click the article number below to view the article in the Microsoft Knowledge Base:
    Q186273 BUG: AV Running VB-Built Component in Multi-Threaded Environment
    NOTE: See Step 7 in the above article.



REFERENCES

A WebClass sample will be located at the following location when you install the MSDN samples:

Microsoft Visual Studio\MSDN98\98VS\1033\Samples\VB98\WcDemo\WCDEMO.VBP


Please see the following Microsoft Knowledge Base articles for more information on WebClasses:
Q189538 BUG: Need to Remove the "Me" References from WcDemo Sample

Q191036 INFO:Option Explicit Statement Is Not Added by WebClass Designer

Q189539 INFO: VB 6.0 Readme Part 8: WebClass Designer Issues

Q191038 INFO: WebClass Initialize, BeginRequest, Terminate Events

Q189540 PRB: Access Denied Error on WebClass Files

Q190253 VB6 Designers Do Not Work in VB5

Q191125 Error Logging Could Have Problems in WebClass Designers

Q191119 FIX: VB Classes Can Cause IIS to Have Access Violations

Q191035 Changes to WebClass Templates Not Always Detected

Q191187 PRB: Don't Modify ASP File Created by the WebClass Designer

Q190252 HOWTO: Change Default HTML Editor


At the following location on the MSDN there is more detailed information about Developing IIS applications:
Visual Basic Concepts/Developing IIS Applications with Webclasses

Visual Basic Documentation\Using Visual Basic\Component Tools Guide\ Building Internet Applications\Developing IIS Applications

Additional query words:

Keywords : kbsample kbInternet kbVBp kbVBp600 kbWebClasses
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 25, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.