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
Post a Comment