STUMPED: IFRAME link won't load until XMLHTTP finishes!?

J

jim.frantzen

You have an active XMLHTTP request on the main page
(localhost/App1/index.aspx) The XMLHTTP request takes about 60 seconds
to receive a response back from localhost/App1/getxml.aspx.

You have an IFRAME on this main page.

When you set the iframe's src to google.com, it works fine.
When you set the iframe's src to localhost/App1/test.htm, it works
fine.
When you set the iframe's src to
localhost/DifferentApplication/index.aspx, it works fine.

When you set the iframe's src to localhost/App1/foo.aspx, IT WONT
LOAD...until the XMLHTTP request has finished.

I'm completely at loss here. fyi: foo.aspx.cs --> Response.Write("hi");

It's like IIS is queuing the requests. BUT, I can make concurrent
XMLHTTP requests and they work fine.

Any experts out there know what's happening?
 
C

Chris Lovett

Are you using async XMLHTTP ? The following test.aspx page retrieves rss
feed from MSDN with a 2 second delay to simulate the slow XMLHTTP request:

<%@LANGUAGE=C#%>
<%@Import Namespace="System.Xml"%>
<%@Import Namespace="System.IO"%>
<%@Import Namespace="System.Net"%>
<%
Response.Clear();
Response.ContentType = "text/xml";

System.Threading.Thread.Sleep(2000);
WebRequest req = WebRequest.Create("http://msdn.microsoft.com/rss.xml");
Stream stm = req.GetResponse().GetResponseStream();
int max = 64000;
byte[] buffer = new byte[max];
int len = 0;
while ((len = stm.Read(buffer, 0, max)) > 0) {
Response.OutputStream.Write(buffer, 0, len);
}
Response.End();
%>


Then the following page loads an IFrame then later displays the result of
the XMLHTTP request once the readyState goes to 4 = "complete":

<%@LANGUAGE=C#%><%
Response.ContentType="text/html";
%>
<html>
<script language=jscript>
var http;
function LoadRss() {
http = new ActiveXObject("MSXML2.XMLHTTP");
http.open("GET", "rss.aspx", true);
http.onreadystatechange = Complete;
http.send("");
}
function Complete() {
window.status = "readyState=" + http.readyState;
if (http.readyState == 4) {
var doc = http.responseXML;
RSS.innerText = doc.xml;
}
}
</script>
<body onload="LoadRss()">
<iframe src="frame.htm">
</iframe>
<xmp id=RSS></xmp>
</body>
</html>

This shows that the IFrame loads fine before the XMLHTTP request is
finished.
 
J

jim.frantzen

The problem I'm having is when both the URL of the XMLHTTP request and
the IFRAME point to pages in the same ASP.NET application.

So to make your code fit this problem, change the Thread.Sleep to
something like 20 seconds. And also change the source of the iframe to
test.aspx.


Then lastly, have a link in the body of your main page that fires
LoadRSS(), then click a link in the Iframe's test.aspx and you'll see
what I'm talking about. The Iframe's won't load until the RSS feed
completes.
 
J

jim.frantzen

Apparently: "XMLHTTP uses WinInet which supports two concurrent HTTP
connections to a given remote server... "

Which does explain some things. However when only one XMLHTTP is
active, I'm strying trying to figure out why an href doesn't respond
until that active xml request terminates.

humm.
 
D

Dr Clue

Apparently: "XMLHTTP uses WinInet which supports two concurrent HTTP
connections to a given remote server... "

Which does explain some things. However when only one XMLHTTP is
active, I'm strying trying to figure out why an href doesn't respond
until that active xml request terminates.

That might be the async parameter in the open method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top