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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -