您可以删除HttpContext.Current.Application["variable"]
中存储的值吗?或者,唯一的方法是将其设置为空字符串?
答案 0 :(得分:6)
您可以使用Application.Remove
,Application.RemoveAll
和Application.RemoveAt
方法。
答案 1 :(得分:3)
使用
HttpContext.Current.Application.Remove("variable");
此外,设置为null
很好,因为如果您尝试阅读HttpContext.Current.Application["variable"]
并且没有值,那么无论如何都会返回null
,但当然最好是明确的你想要的是删除。
答案 2 :(得分:2)
HttpContext.Current.Application.Remove(...)