HOWTO: Use Internet Transfer Control in ASP or in WSH Script |
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.
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:
Url = "http://test"
Inet.OpenUrl (Url, 0)
This code causes the ITC to report "Malformed URL" error. Setting the
URL property fixes this problem.
<HTML>
. . .
This is image 1: <IMG SRC="/image1.jpg"> <hr>
This is image 2: <IMG SRC="http://server/image2.jpg">
. . .
</HTML>
Inet.AccessType = 2
Inet.Proxy = "http://proxy:80"
Not-Recommended Method:
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet SettingsRegistry keys governing proxy settings described in Internet Client SDK are ProxyEnable, ProxyServer, and ProxyOverride. They are also available at the following Web site:
http://msdn.microsoft.com/workshop/default.aspNote 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).
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
Technology :
|
Last Reviewed: May 15, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |