当用户在同一 Web 应用程序中从一个网站集转到另一个网站集时,如何检测事件?
我在同一个 Web 应用程序中有多个网站集,当用户从一个网站集转到另一个网站集时,我需要处理事件。我需要它来执行特定操作,例如设置“lcid”cookie 以更改站点的默认语言和声明值到用户属性映射。
目前,我正在使用自定义 HTTP 模块,该模块处理所有 PostAuthorize Web 应用程序请求并检查当前用户和网站集,保存集合中每个用户上次访问的网站,并在检测到网站集之间的转换时为订阅者触发自定义事件。
但我认为这种方法会降低 Web 应用程序的性能。从日志中我看到,即使用户只是单击其他网站集中页面的链接,也会有很多 PostAuthorize 请求。此外,在类似的情况下,有时会出现一系列对“下一个”网站集的请求,然后对“上一个”网站集的请求,然后再次对“下一个”网站集的请求。当此模块处于活动状态时,SharePoint Designer 也会出现一些问题(无法编辑页面)。
您能为我提供完成这项任务的更好方法的建议吗?提前致谢。
I have a several site collections in the same web application and I need to handle events when user goes from one site collection to another. I need it for specific actions, like setting "lcid" cookie for changing default language of site and claims values to user properties mapping.
Currently I'm using custom HTTP module, which handles all PostAuthorize web application requests and checks current user and site collection, holds last visited site for each user in collection and fires a custom event for subscribers, when detects transition between site collections.
But I think this approach slows down performance of web application. And from logs I see that there are to many PostAuthorize requests even when user simply clicks a link to page in other site collection. Also, in similar cases sometimes there is a series of requests to "next" site collection, then to "previous", and then again to "next". Also there are some issues with SharePoint Designer (can't edit page) become when this module is active.
Could you give me a advice with better approaches for this task? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是使用隐藏控件和 cookie。
在所有目标网站集的所有母版页中保留隐藏控件。
该控件将检查当前网站集 url 并将其保存在 cookie 中。可能在您存储 lcid 的同一个 cookie 中。
从下一次加载开始,它将尝试匹配 cookie 中的 url 和当前网站集 url。如果不同,请调用您要执行的代码并更新 cookie 中的 url。
这比 httpmodule 的性能要轻得多。
1 way is using a hidden control and cookie.
Keep a hidden control in all the masterpage of all the targeted sitecollections.
This control will check the current site collection url and save it in a cookie. Possibly in the same cookie where you are storing lcid.
From next load onwards it will try and match the url in the cookie and the current site collection url. If different call the code you want to execute and update the url in the cookie.
This will be much lighter on performance than an httpmodule.