Reputation: 940
if I add a sessionStorage item via javacrript, is it possible to get that key/value server side using c#.
for example:
Javascript
sessionStorage.setItem("myItem");
Confirm its stored by calling 'sessionStorage.length' in browser console. Returns 1.
C#
Session.Keys.Count; // returns 0
Upvotes: 2
Views: 6978
Reputation: 2544
No, the web server will not have any knowledge of the browser's sessionStorage. The browser's 'session' is completely isolated from the web server's 'session'.
Depending on what type of information you're looking to store and share, you could use cookies. Cookies will be available to both the browser and the web server. Just remember cookies are transmitted both directions with every request so they can add to the cost of each web request.
Alternatively, you could post the new information to an API. This will add an upfront cost but will reduce the cost of each individual web request. This approach assumes the values being posted to the API change less frequently than the number of times the user changes pages.
Upvotes: 6