Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 512
Deane Avatar asked Dec 28 '22 22:12

Deane


1 Answers

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.

like image 192
adrianbanks Avatar answered Jan 03 '23 01:01

adrianbanks