Just downloaded 开发者_如何学JAVAIE9 and pulled up a webproject i have with an IHttpHandler that writes a javascript to the webpage. Before I write the script out, i test to see if the request is from a new session by determining if the session cookie is expired. So here is the strange part, while running the IE debugger, I can see two requests being made to this script, the first one is aborted, then the request is retried.
On the first request, everything goes through like nothing is wrong, no exceptions are thrown. The processing and determination if the request is from a new session executes as expected and I set the cookies accordingly. Then for no reason the request is aborted.
Next, the browser sends a second request through, with the old expired cookies, so it is determined to be a new session and a second session is created. This second request is processed by the browser without error.
This does not occur in FF4, Chrome 10, Safari 5, or even IE9 in compatibilty mode. But get this, it doesnt do it in standard IE9 if the webapp is hosted by VS2010. If I run it in IIS, my sessions get doubled up.
Is there an IIS setting that could be causing this? Or is this an IE9 thing I need to figure out?
I am using Win7 Ultimate N x64 as my dev machine.
update: Another oddity, if I refresh the page with the link to the IHttpHandler, the initial abort does not happen.
update 2: This is posted in the IE9 debugger on the second request:
This download occurred following a preparser restart (often due to either document mode switching or mismatched content encoding between a meta tag in the document and the BOM or a server header).
IE8 and 9 have a pre-parser that runs on the HTTP response stream looking, pretty naively, for URLs to fetch. It then fetches them optimistically, if it's got time and open HTTP sessions, with the idea that it will have them on hand if it later learns it needs them.
This process can be interrupted for a number of reasons, some of which are noted in the debugger message you see: probably, the document mode switched or the content encoding you're using is not the content encoding you think you're using. Does the page start in standards mode, then switch to compatibility mode? (this can be the case if it's an intranet site.) Is there some other switch that happens?
The JavaScript console may contain more information, e.g. HTML1113: Document mode restart from IE9 Standards to Quirks
. In this case, the solution is to select the appropriate DOCTYPE from the beginning so that MSIE does not switch the rendering mode.
Ok, my test page was a plain ol' html page withouth the Doctype specified. Once I put in the
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
it is back to acting normal.
精彩评论