你能删除存储在HttpContext.Current.Application [“variable”]中的值吗?

时间:2011-09-03 10:35:19

标签: c# asp.net

您可以删除HttpContext.Current.Application["variable"]中存储的值吗?或者,唯一的方法是将其设置为空字符串?

3 个答案:

答案 0 :(得分:6)

您可以使用Application.RemoveApplication.RemoveAllApplication.RemoveAt方法。

答案 1 :(得分:3)

使用

HttpContext.Current.Application.Remove("variable");

此外,设置为null很好,因为如果您尝试阅读HttpContext.Current.Application["variable"]并且没有值,那么无论如何都会返回null,但当然最好是明确的你想要的是删除。

答案 2 :(得分:2)

HttpContext.Current.Application.Remove(...)