ASP.NET除去会话中的项目?项目、ASP、NET

由网友(不食人间烟火)分享简介:哪种方法preferred?Session.Remove(富);会话[富] = NULL;时有区别吗?解决方案 时有区别吗?有。Session.Remove(键)删除条目(包括键和放大器;值)从字典,而会话[关键] = NULL 分配一个值(这恰好是空),以一个关键。前者通话结束后,这个密钥不会出现在会话#键集合。但...

哪种方法preferred?

  Session.Remove(富);

会话[富] = NULL;
 

时有区别吗?

解决方案   

时有区别吗?

有。 Session.Remove(键)删除条目(包括键和放大器;值)从字典,而会话[关键] = NULL 分配一个值(这恰好是空),以一个关键。前者通话结束后,这个密钥不会出现在会话#键集合。但在后者,关键仍然可以在领取钥匙找到。

Which method is preferred?

Session.Remove("foo");

Session["foo"] = null;
ASP.NET MVC5网站开发之用户资料的修改和删除3 七

Is there a difference?

解决方案

Is there a difference?

There is. Session.Remove(key) deletes the entry (both key & value) from the dictionary while Session[key] = null assigns a value (which happens to be null) to a key. After the former call, the key won't appear in the Session#Keys collection. But after the latter, the key can still be found in the key collection.

阅读全文

相关推荐

最新文章