从服务器端访问Web存储 - 可能吗? [英] Access web storage from server side - possible?

查看:132
本文介绍了从服务器端访问Web存储 - 可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经存储在网络存储一些字符串(会话和/或本地),想知道是否有可能检查在服务器端的页面加载或init这样存储的字符串(在asp.net C#我情况)......所以,例如,我不知道从数据库重新读取数据,并使用的是已经居住在从最后一页加载浏览器。

I've stored some strings in web storage (session and/or local), and am wondering if it is possible to check for such stored strings on page load or init on the server-side (asp.net c# in my case)... So, for example, I will know not to re-fetch data from the db and use what is already resident in the browser from the last page load.

推荐答案

没有,这是不可能的。 的sessionStorage 住在客户端上。如果你想访问的服务器上,你将不得不写javascript读取的价值,所以它发送给服务器把它在一个隐藏字段。或JavaScript将从存储读取的值,并重定向到将它作为查询字符串参数服务器。但绝对没有办法让服务器直接访问该存储。这是的sessionStorage的VS饼干的缺点之一。

No, that's not possible. sessionStorage lives on the client. If you want to access it on the server you will have to write javascript that reads the value, puts it in a hidden field so that it is sent to the server. Or javascript that will read the value from the storage and redirect to the server passing it as query string parameter. There's absolutely no way for the server accessing directly this storage. That's one of the drawbacks of sessionStorage vs cookies.

这篇关于从服务器端访问Web存储 - 可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆