Skip to content Skip to sidebar Skip to footer

Document.readystate == "complete" Is Always False. The State Is Always "interactive"

I am wiring a startup script JavaScript function on Page_Load to fire like so: ScriptManager.RegisterStartupScript(Me, GetType(Page), 'page_init', 'page_init();', True) This funct

Solution 1:

In order for the ReadyState to flip over to Complete, the server side has to terminate the connection.

If you look at your code you probably aren't calling Response.End AFTER the BinaryWrite or WriteToStream method. This is required in order to flush the response and alert the client that everything has been transferred.

Note that you can still process data server side after making the Response.End call, you just can't send any more data to the client.

A good example of how to do this properly is page 171 of Mastering ASP.Net with C# by A. Russell Jones (google preview here).

The nut of it is that you should create your stream, read it into the Byte Array, close the stream, then do a BinaryWrite, and finally call Response.End.

Solution 2:

I just found out the issue is with an IFrame, which I apologize was a detail left out of the question.

More information can be found here:

IE (surprisingly gets my vote of approval here) There is an onreadystatechange event that fires whenever the iFrame's readyState property changes. That readyState reflects where the download is in the process.

Inline: When you initially set the src value of the iFrame element, the readyState changes to loading. When the file has completely downloaded, the readyState changes to interactive. The big difference between IE and the other browsers is that IE then changes the readyState property to complete when the page (or application) is fully loaded and ready for the user.

Attachment: This behaves identically to the Inline case of IE, but the readyState property never changes to complete. That wouldn't make much sense, since the user has to manually open the file by double-clicking on it or opening it from some application.

Solution 3:

Have you tried calling Response.Close() instead of or before Response.End()? After comparing them in Reflector, it would appear the two are different.

Solution 4:

when writing directly into the stream, you should set the content-length http header to the correct size of the binary data you are sending. It might also be a problem with the content-type (multipart/...) which might confuse the browser.

Post a Comment for "Document.readystate == "complete" Is Always False. The State Is Always "interactive""