开发者

Why would certain browsers request all pages on my ASP.Net Web site twice?

开发者 https://www.devze.com 2022-12-24 07:15 出处:网络
Firefox is issuing duplicate requests to my ASP.Net web site. It will request a page, get the response, then immediately issue the same request again (well, almost the same -- see below). This happens

Firefox is issuing duplicate requests to my ASP.Net web site. It will request a page, get the response, then immediately issue the same request again (well, almost the same -- see below). This happens on every page of this particular Web site (but not any others). IE does not do this, but Chrome also does this.

I have confirmed that there is no Location header in the response, and no Javascript or meta tag in the page which would cause the page to be re-requested (if any of these were true, IE would be re-requesting 开发者_开发知识库pages as well).

I have confirmed this behavior on multiple Firefox installs on multiple machines. Versions vary, but all are 3.x.

The only difference between the two requests is the Accepts header. For the first request, it looks like this:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

For the second request, it looks like this:

Accept: */*

The Content-Type response header in all cases is:

Content-Type: text/html; charset=utf-8

Something else odd -- even though Firefox requests the page twice, it uses the first response and discards the second. I put a counter on a page that increments with every request. I can watch the responses come back (via the Charles proxy). Firefox will get a "1" the first time, and a "2" the second time. Yet it will display the "1," for some reason.

Chrome exhibits this exact same behavior. I suspect it's a protocol-level issue, given the difference in Accepts header, but I've never seen this before.


Check you don't have any img tags with empty src attributes.

FireFox (and apparently Safari and Chrome) will interpret this as a request to the site, giving you the duplicate request.

There is a Mozilla support request about it, and a nice article here discussing what each browser (and each version) does in this scenario.

0

精彩评论

暂无评论...
验证码 换一张
取 消