1
When clicking on a hyperlink in Excel, the ressource will be called three times (or two times, if the URL was visited before). First and second time hidden, third time as expected in a browser.
Details
I am using the HYPERLINK-formular in Excel 2016 like the following one, but the problem also occurs when working without a formular and just the hyperlink-feature:
=HYPERLINK(CONFIRM_NO_DATA_URL&B3)
Anyway, it's supposed to call an URL like this
http://example.org/index.php?action=replyToEmailId&emailId=123123123
When I click the cell, a new tab is opened with the correct URL.
But: The URL actually is being called three times (I noticed it in the first place because three emails were send with a short delay).
I tried to figure out where this came from by putting the Http-Headers to a file. It turned out, excel calls the hyperlink internally moments before it openes the link in a browser. Also the provided Http-Headers differ to the final request.
First hidden request
This is the first request using the HEAD Http-Request-Method:
{
"HTTP_USER_AGENT": "Microsoft Office Excel 2014 (16.0.10730) Windows NT 10.0",
"HTTP_X_OFFICE_MAJOR_VERSION": "16",
"HTTP_X_MS_COOKIEURI_REQUESTED": "t",
"HTTP_X_FEATUREVERSION": "1",
"HTTP_ACCEPT_AUTH": "badger,Wlid1.1,Bearer",
"REMOTE_PORT": "50216",
"REQUEST_METHOD": "HEAD",
"REQUEST_TIME_FLOAT": 1537284526.406,
"REQUEST_TIME": 1537284526
}
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. source: [w3.org][1]
Second hidden request
The second request is kind of hard to identify, looks like Excel mocks several user agents:
{
"HTTP_ACCEPT": "*\/*",
"HTTP_USER_AGENT": "Mozilla\/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident\/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; ms-office)",
"HTTP_ACCEPT_ENCODING": "gzip, deflate",
"REMOTE_PORT": "50221",
"REQUEST_METHOD": "GET",
"REQUEST_TIME_FLOAT": 1537284527.807,
"REQUEST_TIME": 1537284527
}
Question
How to prevent this behaviour on Excel-side?
(Sure I can prevent it in my PHP-script by blocking the HTTP_USER_AGENT containing "ms-office" or the REQUEST_METHOD "HEAD", but I prefer a clean solution).
Side notes
UPDATE #1
I just found this SO-question, which kinda describes the same behaviour: https://stackoverflow.com/questions/24993813/link-in-excel-cause-duplicate-invocation
UPDATE #2 While digging deeper into this I find more and more kind-of-connected SO-threads, like this, which gives a nice description of this "feature": https://webmasters.stackexchange.com/a/71151
Though, there is a slight difference. The REQUEST METHOD of the first request in my case is HEAD, not OPTION as in the above mentioned answer. Anyway, this still does not help me solving the problem.
UPDATE #3 While trying to reproduce this I found out there are not two but three requests made.
Yes, I also noticed that. It seems to be kind of a feature, but it would be great to prevent Excel from doing it. For me, as a user, it is also totally okay and also no difference, when I receive a 404 in my actual browser. – n.r. – 2018-09-18T13:47:09.690