简体   繁体   English

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

[英]Can you delete values stored in HttpContext.Current.Application[“variable”]?

Can you delete values stored in HttpContext.Current.Application["variable"] ? 你能删除存储在HttpContext.Current.Application["variable"]吗? Or is the only way to do this is by setting it to an empty string? 或者唯一的方法是将其设置为空字符串?

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

Use 采用

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

Also, setting to null is fine since if you try to read HttpContext.Current.Application["variable"] and there is no value there, it will return null anyway, but of course better to be explicit if what you want is remove. 此外,设置为null很好,因为如果你尝试读取HttpContext.Current.Application["variable"]并且那里没有值,它仍然会返回null ,但当然如果你想要的东西被删除,最好更明确。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM