Is GetHashCode just a cargo cult?

HttpContext.Current.Items["ctx_" + HttpContext.Current.GetHashCode().ToString("x")]

I see this exact code all ... over ... ... the place , but I have to ignore something. Answers to these messages often raise the question of the appropriateness of using an HttpContext, but no one indicates that GetHashCode is redundant and a fixed line will do.

What am I not seeing here?


EDIT: The question is, GetHashCode () will be the same for every HttpContext.Current, so why use GetHashCode () in the four links I provided? Some of them are recordings with quite a lot of work, so I feel that maybe they solve some problems with threads or context that I skip. I don’t understand why just HttpContext.Current.Items ["ctx_"] will not do the same.

+5
source share
2 answers

. -, HttpContext.Current.Items HttpContext, " ". -, , , , , .

(, , ), , Guid.NewGuid().ToString(). .

+1

, :)

GetHashcode . , , , , . - .

, .

["ctx_" + HttpContext.Current.GetHashCode().ToString("x")]

["object_context_key"]

- . , , ( , , post mortem), , - , , " ", GetHashCode.

+1

All Articles