HOWTO: Use Internet Transfer Control in ASP or in WSH Script

ID: Q188955


The information in this article applies to:


SUMMARY

Even though it is possible to use the Internet Transfer Control (ITC) on an Active Server Pages (ASP) page to retrieve HTTP URLs, neither the ITC nor WinInet APIs used by the ITC was designed to be used as a server component. Please thoroughly test your application under stress conditions before using it in the production environment.


MORE INFORMATION

IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore the registry if a problem occurs. For information about how to do this, view "Restoring the Registry" Help topic in Regedit.exe or "Restoring a Registry Key" Help topic in Regedt32.exe.

ITC exposes two methods that allow URL downloads: Execute and OpenUrl. It is not possible to use the Execute method in the Windows Script Host script or on an ASP page. VBScript does not support late binding of events; therefore, StateChange notification will never be called.

You can get around this issue by using the OpenUrl method as shown in the following snippet of an ASP page (VBScript is used):


   <%
   Set Inet = Server.CreateObject("InetCtls.Inet.1")
   Inet.RequestTimeOut=20
   Inet.Url = Request.QueryString ("url")
   s = Inet.OpenURL
   response.write(s)
   %> 
Please note the following problems/issues:

This registry location is not available from ASP scripts; therefore, the ITC will not be able to retrieve proxy information. This situation may be remedied as follows.

Following are the methods for using the ITC with the Proxy setting on the ASP page.

Recommended Method:

Setting proxy properties for the ITC on the ASP page as follows:



   Inet.AccessType = 2
   Inet.Proxy = "http://proxy:80"
 
Not Recommended Method:

By modifying the registry hive of the default user.

WARNING: Using the Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use the Registry Editor at your own risk.

For information about how to edit the registry, view "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. NOTE: You should back up the registry before you edit it. If you are running Windows NT, you should also update your Emergency Repair Disk (ERD).

You can copy relevant Internet connection values from the HKCU to this default location (and make it available to the control created on the ASP page):


   HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet
   Settings 


Registry keys governing proxy settings described in Internet Client SDK are ProxyEnable, ProxyServer, and ProxyOverride. They are also available at the following Web site:

http://www.microsoft.com/msdn/sdk/inetsdk/help/


Note that anonymous ASP requests are handled in the security context of the anonymous Internet user - IUSR_COMPUTER_NAME by default. Make sure to add security permissions for this user to access the above mentioned registry keys. You can do this by going to the Security menu option of the Registry Editor (regedt32.exe).


REFERENCES

Microsoft Internet Transfer Control Help Microsoft Internet Client SDK

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Leon Braginski, Microsoft Corporation.

Additional query words: ASP ITC MSINET OpenUrl kbInternet kbASP kbWinInet


Keywords          : kbWinInet 
Version           : WINDOWS:2.0; winnt:
Platform          : WINDOWS winnt 
Issue type        : kbhowto 

Last Reviewed: July 13, 1999