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 -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -