Microsoft KB Archive/191039

= How To Build an Internet Information Server Application =

Article ID: 191039

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q191039



SUMMARY
This article describes how to build a Microsoft Internet Information Server (IIS) application in Visual Basic.



Steps to Build a Simple IIS Application
 Start Visual Basic. In the New Project dialog box, select IIS Application, and then click Open. In the Project Explorer, select Project1 (Project1). In the Properties window, modify the Name property to give your project a name. On the File menu, click Save Project.

NOTE: You cannot continue to the next steps to import an HTML file until you save the project. In the Project Explorer, click to expand the Designers folder. Right-click WebClass1 (WebClass1.Dsr), and click View Object on the shortcut menu. The WebClass designer window appears. Right-click the HTML Template WebItems folder, and click Add HTML Template to add an HTML file to your project. By default, this HTML Template WebItem is called Template1 in the WebClass designer window.

NOTE: If the xxx.htm file that you select is in your project's working directory, the WebClass designer makes a copy of the xxx.htm file (named xxx1.htm) and places it in the working directory of your project. xxx1.htm is the HTML file that the WebClass designer makes changes to. If the xxx.htm file that you select is not in the working directory of your project, the WebClass designer places a copy of the file (with the same name) in the working directory of your project.  In the Project Explorer, right-click WebClass1 (WebClass1.Dsr), and click View Code on the shortcut menu. Replace the WebClass Start event code with the following code:

Private Sub WebClass_Start Set NextItem = Template1 end Sub You use the NextItem property to shift processing from one WebItem to another during a single request. This causes the Template1_Respond event to fire.   Paste the following code in the Template1_Respond event:

Private Sub Template1_Respond Template1.WriteTemplate End Sub

The WriteTemplate method sends the contents of Template1 to a client browser window. (Template1 is the HTML file that you imported into the IIS application.) If you do not put anything in this event, and you run the project, the browser displays a blank page.  Press the F5 key to run the project. The Project Properties dialog box appears in Visual Basic. On the Debugging tab, make sure that Start component is set to WebClass1, and then click OK. The WebClass designer prompts you to create a Virtual Root, which is required in order to run the WebClass. After you enter a name for the Virtual Root, click OK.</li>  The page that you created now appears in the browser. After you browse the project, click End on the Run menu in Visual Basic. In the Project Explorer, right-click WebClass1 (WebClass1.Dsr), and then click View Code on the shortcut menu. Replace the Template1_Respond event code with the following code to create a second example: Private Sub Template1_Respond 'Write a reply to the user. With Response .Write " " .Write " " .Write " WebClass1's Starting Page " .Write " Response was created in the Template1_Respond event " .Write " " .Write " " End With End Sub </li> Press the F5 key to run the project. After you browse the project, click End on the Run menu in Visual Basic.</li> On the Project menu in Visual Basic, click <Project Name> Properties. On the General tab, select the following project properties check boxes for optimal performance: <ul> Retain In Memory</li> Unattended Execution</li> Apartment Threaded for the Threading Model</li></ul>

For additional information on these settings and other possible issues, click the article number below to view the article in the Microsoft Knowledge Base:

186273 BUG: AV Running VB-Built Component in Multi-Threaded Environment

</li></ol>

<div class="references_section">