c# - Using the indexer of HttpResponse.Cookies will add a cookie to the response and to the request. What is the idea behind this? -


i realized this, when website returned empty cookies, after had replaced legacy code usage of httpcontext.response.cookies via indexer. example:

httpcookie objcookie = httpcontext.response.cookies["trackingid"]; line add cookie named "trackingid" response , request, if not exists yet.

to me sort of surprising have never expected such drastic behavior simple get-call on indexer; especially, when collection has dedicated "add"-method. also, indexer has setter.

the documentation says:

after add cookie using httpresponse.cookies collection, cookie available in httprequest.cookies collection, if response has not been sent client.

i found way avoid problem. question is:

why make class behave way?


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -