-
ServerXMLHTTP and frozen frames
Hello,
I have an ASP frameset with 2 frames, menu.asp and body.asp. Menu.asp is
using ServerXMLHTTP to retrieve the contents of an HTML page on the Internet
and save the responseText to a local file. While menu.asp is retrieving this
page (anywhere from 1 second to 30 seconds depending on traffic), body.asp
is unable to be navigated. I understand I could run this asynchronously,
but I still need to wait for the page to be retrieved (using waitForResponse)
in order to insure that I have the responseText to save to the local file.
While this is happening, I expected that only menu.asp would be "locked",
but it turns out that body.asp is also "locked". Is there a way around this?
Below is the source of menu.asp:
...
'create a new XMLHTTP object instance
Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
'Get the Source page
objHTTP.open "GET", "http://www.yahoo.com", True
objHTTP.Send
'Await the response
While objHTTP.readyState <> 4
objHTTP.waitForResponse
Wend
'Get the HTML from the Source page
SiteHTML = objHTTP.responseText
Set objHTTP = Nothing
'Create a local file
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFile = fso.CreateTextFile("c:\pages\localyahoopage.htm", True)
'Write the Source's HTML to the local file and save it
objFile.Write(SiteHTML)
objFile.Close
Set objFile = Nothing
Set fso = Nothing
...
Thank you,
Greg Ferris
-
Re: ServerXMLHTTP and frozen frames
The problem, as far as I see, was that you used async call with a kind of
"dead" loop on a single thread to wait for download completion. Your loop
locked down your own page which utilizes CPU time for doing nothing. A better
way to do this is: remove the loop and use a different and better mechanism
to check the download status (say, use a completion flag somewhere in the
ASP cache memory, or use an event handler in JavaScript on the client side
to free up the UI thread, etc).
BTW, ServerXMLHTTP can be extremely fast if you call it only from MTA (delegate
the call to an MTA component). On my single P3 650MHz PC earlier, ServerXMLHTTP
(v3) could support 100-150 downloads per second from randomly selected URLs.
-HQ
"Greg Ferris" <gregory@ferris.net> wrote:
>
>Hello,
>I have an ASP frameset with 2 frames, menu.asp and body.asp. Menu.asp is
>using ServerXMLHTTP to retrieve the contents of an HTML page on the Internet
>and save the responseText to a local file. While menu.asp is retrieving
this
>page (anywhere from 1 second to 30 seconds depending on traffic), body.asp
>is unable to be navigated. I understand I could run this asynchronously,
>but I still need to wait for the page to be retrieved (using waitForResponse)
>in order to insure that I have the responseText to save to the local file.
>While this is happening, I expected that only menu.asp would be "locked",
>but it turns out that body.asp is also "locked". Is there a way around this?
>
>Below is the source of menu.asp:
>
>...
>'create a new XMLHTTP object instance
>Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
>
>'Get the Source page
>objHTTP.open "GET", "http://www.yahoo.com", True
>objHTTP.Send
>
>'Await the response
>While objHTTP.readyState <> 4
> objHTTP.waitForResponse
>Wend
>
>'Get the HTML from the Source page
>SiteHTML = objHTTP.responseText
>Set objHTTP = Nothing
>
>'Create a local file
>Set fso = CreateObject("Scripting.FileSystemObject")
>Set objFile = fso.CreateTextFile("c:\pages\localyahoopage.htm", True)
>
>'Write the Source's HTML to the local file and save it
>objFile.Write(SiteHTML)
>objFile.Close
>
>Set objFile = Nothing
>Set fso = Nothing
>
>...
>
>Thank you,
>Greg Ferris
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|