Which method is preferred?
Session.Remove('foo'); Session['foo'] = null;
Is there a difference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is.
Session.Remove(key)deletes the entry (both key & value) from the dictionary whileSession[key] = nullassigns a value (which happens to be null) to a key. After the former call, the key won’t appear in theSession#Keyscollection. But after the latter, the key can still be found in the key collection.