Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you delete values stored in HttpContext.Current.Application["variable"]?

Tags:

c#

asp.net

Can you delete values stored in HttpContext.Current.Application["variable"]? Or is the only way to do this is by setting it to an empty string?

like image 974
Theomax Avatar asked Nov 24 '25 09:11

Theomax


2 Answers

You can use Application.Remove, Application.RemoveAll, and Application.RemoveAt methods.

like image 132
KV Prajapati Avatar answered Nov 26 '25 22:11

KV Prajapati


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.

like image 35
Meligy Avatar answered Nov 26 '25 22:11

Meligy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!