I have code similar to the following:
this.Session[key] = "foo"; if ((this.Session[key] ?? string.Empty) == "foo") {
This, of course, creates the situation "Possible unintentional comparison of links made for the intended purpose." The solution to this is well documented here, and I already knew that the fix was to pass the session variable to string as soon as I saw the code.
However, the year code never changed since it was originally written. Until this week, in our test environment, the if was evaluated as true and executed the //do stuff section. This erroneous code STILL WORKS, as provided for in our production environment.
How can it be? There is no reason why this code, as written, should ever work as intended; and yet he did it and still does in production. And what would have changed so that this code, which should not have worked, but did, suddenly stops working (or, rather, behave the way it should always be)?
source share