468,457 Members | 1,762 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,457 developers. It's quick & easy.

REAL asynch XmlHttp with IE

Ric
I created a page in ASP.Net (with no buffering) that does the following:
Output line #1
FLUSH
{wait 1 second}

Output line #2
{wait 1 second}

Output line #3
FLUSH
......etc

If I browse to the page, you can see that the response comes back as a
STREAM, as it happens. (Note you can only see this the SECOND time the page
is loaded in IE)

When I use XmlHttp in IE, the response only comes back when the WHOLE page
is done. However, in other browsers, it works as expected. The
onreadystatechange raises the event in my JS callback function when the
document is complete, but FireFox raises it for each FLUSH, which is the
effect I need. I would like to know if anyone else can make IE XmlHttp object
do the stream.

Example code: (C#)

private void Page_Load(object sender, System.EventArgs e)
{
Response.ClearContent();
Response.BufferOutput = false;

Response.Write("Output line #1<br/>" + CRLF);
Response.Flush();
System.Threading.Thread.Sleep(1000);

Response.Write("Output line #2<br/>" + CRLF);
Response.Flush();
System.Threading.Thread.Sleep(1000);

//etc..
Techniques I have tried:
1) Asynch Http Module - the module worked, but the client side still did not
2) JavaScript work arounds:
a) Polling
b) Remote Scripting (this works, but must use a GET, and so is not as
secure)
c) Timeouts (too many requests)
3) HTA - also works, but only on IE

Any help would be appreciated!
Nov 19 '05 #1
5 1675
The problem in IE is that IE is being as strict as XML is. The document is
not well-formed until all opening tags are closed. This is likely to cause
problems with other browsers as well. If not now, perhaps later.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Ric" <Ri*@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
I created a page in ASP.Net (with no buffering) that does the following:
Output line #1
FLUSH
{wait 1 second}

Output line #2
{wait 1 second}

Output line #3
FLUSH
.....etc

If I browse to the page, you can see that the response comes back as a
STREAM, as it happens. (Note you can only see this the SECOND time the
page
is loaded in IE)

When I use XmlHttp in IE, the response only comes back when the WHOLE page
is done. However, in other browsers, it works as expected. The
onreadystatechange raises the event in my JS callback function when the
document is complete, but FireFox raises it for each FLUSH, which is the
effect I need. I would like to know if anyone else can make IE XmlHttp
object
do the stream.

Example code: (C#)

private void Page_Load(object sender, System.EventArgs e)
{
Response.ClearContent();
Response.BufferOutput = false;

Response.Write("Output line #1<br/>" + CRLF);
Response.Flush();
System.Threading.Thread.Sleep(1000);

Response.Write("Output line #2<br/>" + CRLF);
Response.Flush();
System.Threading.Thread.Sleep(1000);

//etc..
Techniques I have tried:
1) Asynch Http Module - the module worked, but the client side still did
not
2) JavaScript work arounds:
a) Polling
b) Remote Scripting (this works, but must use a GET, and so is not as
secure)
c) Timeouts (too many requests)
3) HTA - also works, but only on IE

Any help would be appreciated!

Nov 19 '05 #2
while Mozilla/Firefox/safari copied the XMLHTTP object, they coded for use
in the browser (even adding SOAP support), while the microsoft version is
actually part the msxml kit. it doesn't support async (the ServerXmlHTTP
does, but can not be used by the browser).

to do what you want, i'd poll with xmlhttp (no sleep, each one is its own
request) or use the iframe pattern. using document.write and an iframe you
can pass as mush data to the server as you want. the server can flush code
like

Response.Write(string.Format(@"<input type=hidden id=foo" value="{0}">
<script>parent.processData(document.getElementById ('foo').value);</script>",
HttpUtility.HtmlEncode("myvalue"));
Response.Flush();
-- bruce (sqlwork.com)

"Ric" <Ri*@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
I created a page in ASP.Net (with no buffering) that does the following:
Output line #1
FLUSH
{wait 1 second}

Output line #2
{wait 1 second}

Output line #3
FLUSH
.....etc

If I browse to the page, you can see that the response comes back as a
STREAM, as it happens. (Note you can only see this the SECOND time the
page
is loaded in IE)

When I use XmlHttp in IE, the response only comes back when the WHOLE page
is done. However, in other browsers, it works as expected. The
onreadystatechange raises the event in my JS callback function when the
document is complete, but FireFox raises it for each FLUSH, which is the
effect I need. I would like to know if anyone else can make IE XmlHttp
object
do the stream.

Example code: (C#)

private void Page_Load(object sender, System.EventArgs e)
{
Response.ClearContent();
Response.BufferOutput = false;

Response.Write("Output line #1<br/>" + CRLF);
Response.Flush();
System.Threading.Thread.Sleep(1000);

Response.Write("Output line #2<br/>" + CRLF);
Response.Flush();
System.Threading.Thread.Sleep(1000);

//etc..
Techniques I have tried:
1) Asynch Http Module - the module worked, but the client side still did
not
2) JavaScript work arounds:
a) Polling
b) Remote Scripting (this works, but must use a GET, and so is not as
secure)
c) Timeouts (too many requests)
3) HTA - also works, but only on IE

Any help would be appreciated!

Nov 19 '05 #3
Ric
Kevin,

I am sorry, but I do not think this has anything to do with well formed Xml.
The data sent back is actually valid XhtML.

Also, I am using the msXmlHttp .ResponseBody property not .Xml

Than you
Nov 19 '05 #4
Ric
Bruce,

The msXmlHttp does return for each method: when I set the mthod, .Open the
connection, and receive the data. So it is _kind_of_ ansyncronous in that my
other javaScript events may respond.

I hoping there may be a property that I maight be able to set or maybe use
the .ResponseXml to get the data as it comes out.

I am afraid you may be correct: while I may be able to code around the issue
with timeouts or remote scripting, msXmlHttp object does not give me the
response stream as it is sent - it waits until the whole document is done.

Is is unfortunate that Microsoft inveted this capability, but has not
implemented this obvious use, but Mozilla has. Do you know of any existing
remote scripting that works like the XmlHttp object (not frames!)?

Nov 19 '05 #5
Ric
It looks like this problem is with Internet Explorer and not just XmlHttp
object
I put an example up on http://www.ECMASCRIPT.net/
If you click on the link in Firefox you get the document as it streams.
If you click on the link in IE, it waits until the whole document is done
the first time. If you hit refresh on /TimedOutput.aspx you get the same as
firefox.

The button simply uses the Xmlhttp object to request the same page and
display the result as it get it. It works well in fireFox, but not IE

Is this a header problem? Or did I set up IIS wrong? Can I write my Asp.Net
Page any way to fix this?

Any help would be appreciated!
Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by MasterBlaster | last post: by
11 posts views Thread by Glen Wolinsky | last post: by
9 posts views Thread by balakrishnan.dinesh | last post: by
2 posts views Thread by Techno_Dex | last post: by
4 posts views Thread by EM_J | last post: by
13 posts views Thread by yawnmoth | last post: by
reply views Thread by Patino | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by subhajit12345 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.