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