你可以删除存储在HttpContext.Current.Application [“variable”]中的值吗?
问题描述:
你可以删除存储在HttpContext.Current.Application["variable"]
中的值吗?或者唯一的方法是将其设置为空字符串?你可以删除存储在HttpContext.Current.Application [“variable”]中的值吗?
答
您可以使用Application.Remove
,Application.RemoveAll
和Application.RemoveAt
方法。
答
使用
HttpContext.Current.Application.Remove("variable");
此外,设置null
是好的,因为如果你尝试读取HttpContext.Current.Application["variable"]
并没有价值在那里,它将返回null
无论如何,但当然更好,如果你想要什么明确是删除。
答
HttpContext.Current.Application.Remove(...)