Share via


IIS Samples - Simple VB Component

This is the Microsoft Visual Basic (VB) version of the Power sample object. It demonstrates how to write a component whose methods can be called from an ASP page. This component in turn accesses the intrinsic ASP objects using the COM GetObjectContext object.

important Important These samples are provided for educational purposes only. They are not intended to be used in a production environment, have not been tested in a production environment, and Microsoft does not provide technical support for them.

Sample Overview
Requirements
Location of the Source Code
Build and Install the Sample
Run the Sample
Sample Output
Helpdesk

Sample Overview

This sample accesses the intrinsic ASP objects to test what type of Web browser the client is using.

to top

Requirements

This sample requires the installation of the following software to function properly:

  • Windows XP Professional with IIS 5.1 installed or Windows .NET Server with IIS 6.0 installed.
to top

Location of the Source Code

IIS samples are included in the IIS Software Developer Kit (SDK). You can download the IIS SDK from Platform SDK Update. You can view the SDK at MSDN Online. In the table of contents at MSDN Online, click Web Development, Server Technologies, Internet Information Services (IIS), SDK Documentation, Internet Information Services, Samples.

The following source code files are required for this sample:

File Description
VB_Simple.vbp Simple Visual Studio 6.0 project file, required to build this sample using Visual Basic 6.0.
VB_Simple.cls Simple source module containing the code that implements the sample.
VB_Simple.asp Simple Web file, required to illustrate how the sample comppnent is used from an ASP page.
to top

Build and Install the Sample

To build this sample using Visual Basic, the following steps need to be performed:

  1. Copy the sample to a physical folder on your computer. For example, create a folder called C:\Samples and copy the files to that folder.
  2. Set strong security on your folder. For more information, click Start, Help and Support, and search for Access Control. It is wise to restrict access to folder on your computer to the Administrators group, and in this case, the IIS_WPG group.
  3. Open the project file in VB.
  4. Click File, Make VB_Simple.dll, and click OK in the Make Project window. This builds and registers the Simple VB component.

</Non-C++ Sample>

To install this sample, the following steps must be performed:

  1. Copy the VB_Simple.asp file to a physical folder on your computer. For example, create a folder called C:\Samples and copy the files to that folder.
  2. Create a virtual directory that maps to the physical folder containing your files. To create a virtual directory, open Internet Information Services (IIS) Manager by clicking Start, Run, type inetmgr in the text box and click OK. Right-click the Web site where you want to create a virtual directory, click New, and click Virtual Directory. In the Alias text box, type the name you want for your virtual directory, for example, Simple. In the Directory text box, type the path to the folder that contains your files.
  3. Configure strong security on your new virtual directory. Right-click the virtual directory name, click Properties, and click the Directory Security tab. Press F1 for tips on securing your virtual directory.
  4. Use Windows Explorer to set restricted access control on the sample .dll file in its physical folder. For more information, click Start, Help and Support, and search for Access Control.
to top

Run the Sample

In order to run this sample, follow the instructions listed below:

  1. Browse to your sample Web files in Internet Explorer (IE). For example, if your files are in a virtual directory called Simple, type https://localhost/Simple/VB_Simple.asp in the Address bar of IE.
to top

Sample Output

The following output is displayed somewhere after you perform step 1 from Run the Sample.

  Testing VB_Simple
  myProperty Value = Visual Basic 5 Power Component
  Set myProperty to Power
  myProperty Value is now: Power
  Call myMethod with My String: MY STRING
  MyPowerMethod returns: You are using a very powerful browser.
  MyPowerProperty returns: /Simple/VB_Simple.asp
to top

Help Desk

If here you do not find answers to your questions, visit the Microsoft Help and Support Web site.

Problem Possible Solution
When browsing to the ASP page, IE returns HTTP 404 - File not found Verify that you have created a virtual directory of the same name you are typing in the Address box of IE.
When building the dll, VB returns the a permissions error. Once you have called the dll from your web page, your system considers it a loaded dll. You must unload it to build it again, either by unloading the ASP application or deleting the dll from system32\dllcache.
to top