c# - HttpCookieCollection.Get(): Possible NullReferenceException -


i see resharper warning 'possible nullreferenceexception' on code on second line:

var cookie = httpcontext.current.response.cookies[cookiename]; cookie.expires = datetime.now.adddays(-1); 

i checked httpcookiecollection.get() method in msdn , says 'if named cookie not exist, method creates new cookie name.'. looks nullreferenceexception can't happen.

is resharper bug or missed something?

so looks nullreferenceexception can't happen.

httpcontext.current null if execute code outside of asp.net context, example unit test, console or desktop application.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -