在页面之间保留值/变量
我想知道是否有另一种解决方案可以解决我的问题,这被认为更像是 Sharepoint 方式。首先,我的站点是一个 Internet 站点,而不是 Intranet。问题是,我想做的就是在 Sharepoint 中逐页保存值/变量。我知道会话变量的问题,但这似乎是我能看到完成此任务的唯一方法。我知道有些 Web 部件可以存储此值,但我认为这不会在页面之间保留,这是错误的吗?
基本上,我将扩展内容查询 Web 部件以根据变量/值动态筛选其结果。用户从下拉列表中选择他们的“区域”,站点中的 CQWP 将根据该值更改并查询结果(这将是一个省级结构,因为它是加拿大站点,因此如果有人选择省“安大略省” ,该值保存在全局变量中,并且整个站点中的这些扩展 CQWP 将获取该值,并且查询列表标记为安大略省)。
Session 变量是唯一的解决方案吗?
谢谢大家!
I'm wondering if there's another solution to my problem, that's considered more the Sharepoint way. FIrstly, my site is an Internet site, not Intranet. The problem is, all I'm trying to do is save values/variables from page to page in Sharepoint. I know the issue with Session Variables, but this seems to be the only way I can see to accomplish this. I know there are webparts that can store this value, but am I wrong in thinking this won't be persisted from page to page?
Basically, I'll be extending the Content Query Web Part to dynamically filter it's results based off of a variable/value. The user chooses their 'area' from a dropdown, and the CQWP in the site will change and query results based off of this value (It will be a provincial structure as it is a Canadian site, so if someone chooses the province 'Ontario', this value is saved in a global variable, and these extended CQWP that are throughout the site, will get this value, and query lists flagged as Ontario).
Is Session variables the only solution?
Thanks everyone!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
会话变量不是唯一的解决方案。您也可以使用浏览器 Cookie。
不一定是“SharePoint 方式”,但它是一种选择。
Session variables are not the only solution. You can use Browser Cookies as well.
Not necessarily the 'SharePoint Way', but it is an option.
SharePoint 方式可能是使用用户配置文件中的某些内容,尽管这当然不适合匿名网站。不必太担心超出 SharePoint 的处理方式 - 对于 Internet 网站来说,这几乎是不可避免的。
如果您只需要存储一个值,我会推荐使用 cookie 而不是会话变量 - 易于从客户端或服务器代码使用,并且不会出现会话带来的潜在存储问题。
The SharePoint way would probably be to use something in the user profile, although of course that's not as appropriate for an anonymous site. Don't worry too much about going outside the SharePoint way of doing things - with an internet site it's pretty much unavoidable.
I'd recommend a cookie rather than a session variable if you only need to store the one value - simple to use from either client or server code, and none of the potential storage issues you get with the session.
您始终可以使用数据库来保存此类数据。没有提及 SharePoint 场场景中的会话问题。
You can always use database to persist this kind of data. Not mentinoning problems with sessions in SharePoint farm scenario.
您可以在 Web 或 Web 应用程序级别读取、写入或删除持久键/值,请查看 SPWeb.Properties 属性。
You can read or write or remove persist key/values in web or webapplication level, take a look at SPWeb.Properties Property.