HOWTO: Use Internet Transfer Control in ASP or in WSH ScriptID: Q188955
|
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>
[ASCII 133]
This is image 1: <IMG SRC="/image1.jpg"> <hr>
This is image 2: <IMG SRC="http://server/image2.jpg">
[ASCII 133]
</HTML>
Inet.AccessType = 2
Inet.Proxy = "http://proxy:80"
Not Recommended Method:
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet
Settings
http://www.microsoft.com/msdn/sdk/inetsdk/help/
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