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

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

问题描述:

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

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

使用

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

此外,设置null是好的,因为如果你尝试读取HttpContext.Current.Application["variable"]并没有价值在那里,它将返回null无论如何,但当然更好,如果你想要什么明确是删除。

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