Not entirely sure how to go about explaining this problem so feel free to request further info, code samples etc. if I miss something relevant!
I have an ASP.NET MVC web application which runs fine locally and on the server, but some browsers on some computers (seems random, so far) error on a certain function, same function for all affected each time (so far). No errors reported on the server. No fancy custom cookies - just defaults & basic out of the box Identity login.
The first time this occurred, it was when previewing a PDF (produced by rotativa) prior to printing. Some of my clients computers were hitting this error in chrome, some were not. Sometimes switching to a different browser worked. I was unable to replicate the problem on 2 Windows & 1 Android devices.
Clearing cookies for the site on all affected computers resolved the problem.
Fast forward a couple of weeks and a different function seems to be having the same problem - works on my machines, fine on some client machines, but others get an error. I'm told clearing cookies didn't work (although I am unsure if the user did so properly as I wasn't on-site).
However, when we tried doing the same function, same computer, same browser, but in incognito mode, it worked like a charm.
IIRC the error given in the console is 500 Internal Server Error (I've only seen it once), however event viewer on the server does NOT record an error.
The first time, no changes had been made to the code of the offending function in some time. This current incarnation of the problem is after a significant update, but since it isn't happening across the board, I'm doubtful that it is related to the update.
Since clearing cookies and using incognito mode seem to help, this seems to point at cookies being somehow related to the issue. I've never really worked directly with cookies so I am unsure where to start looking for a solution. When I have a look at the cookies for the site on my machine right now, I see...
Unfortunately I did not think to look at cookies on the client machines while I was there. All machines except one (chrome on iOS, so far so good there) are Windows, plus I've used my Android phone a few times (with no issues)
Unsure if this is relevant, but this latest instance of the problem is occurring on a jQuery.post(). The previous occurance was on a button with a link created using @Url.Action() with jquery .click() on the button on page load.
I would greatly appreciate any advice on where I should be looking for the cause and solution to this problem, as I am completely lost lol!
Thanks to @pfx for this solution (if you put it in an answer I'll accept it!)
I have a javascript file which contains some functions shared by a couple of pages, on each page which uses that file I modified the reference to add the current datetime in ticks as a temporary test to see if it resolved the problem. So far it seems to have done the trick.
In case anyone else, like me, hasn't encountered this before, here's an example of a quick test fix.
<script src="~/Scripts/SharedScripts.js?dt=@(DateTime.Now.Ticks)"></script>
This will force it to get a new copy of the file every load, so not ideal.
There are better solutions for the long term which will only force the browser to get a fresh copy when it has changed (version numbers or hash of content, for example). So now I'll look at implementing one of those!
Just as an aside, this still doesn't explain the original incidence of this problem, as there is no script file used in that case - however clearing cookies worked there, (but not this time) so maybe it was some kind of cookie corruption in that case.