最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

C#Javascript Session Storage - Stack Overflow

programmeradmin6浏览0评论

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

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
Share Improve this question asked Mar 25, 2015 at 19:42 ManxJasonManxJason 94013 silver badges34 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

No, the web server will not have any knowledge of the browser's sessionStorage. The browser's 'session' is pletely 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.

发布评论

评论列表(0)

  1. 暂无评论