Reputation: 847
I have a system where I save temporary variables using sessionStorage (javascript).
How can I do to clean them in C # inside a controller?
Tried HttpContext.Session.Clear()
But I was unsuccessful, the variable remains active until I close the browser.
Upvotes: 0
Views: 2863
Reputation: 1570
See @Sam Axe's answer.
HttpContext.Session.Clear() is .NET context (server side). The sessionStorage is JavaScript, so you have to call:
sessionStorage.clear();
on the client side, so in the JavaScript code, possibly on some event button click, etc.)
ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
Upvotes: 1