使用 SharePoint 中 pageviewerwebpart 内的程序获取页面 URL
我有一个用 c# .net 编写的简单点击计数器。我使用 pageviewerwebpart 将该计数器放置在许多页面上。我想要做的是,不仅计算点击次数,还计算哪个页面触发了点击计数器。那么如何使用点击计数器检索页面 URL 呢?
谢谢。
I have a simple hit counter written in c# .net. I placed that counter to many pages using the pageviewerwebpart. What I want to do is, not only counting the hits, but also which page triggered the hit counter. So how can I retrieve the page URL with my hit counter ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看 Request.ServerVariables。
您可能正在寻找
Request.ServerVariables["URL"]
。Have a look at Request.ServerVariables.
You are probably after
Request.ServerVariables["URL"]
.获取链接到当前页面的页面的 url 使用:
如果您的应用程序位于 IFRAME 中,您可以使用它进行检查,
但由于跨脚本安全问题,仅当在同一域/站点 url 上运行时才有效。
The get the url of the page that linked to the current page use:
if your app is in say an IFRAME you can check it using
this works only when running on the same domain / site url though, because of cross scripting security issues.
这与我在 url 方面遇到的问题相同。您可以在 page_load 子项中使用
Request.UrlReferrer.ToString()
,但它仅在页面首次加载时有效。如果您进行刷新,则会获取 pageviewerwebpart 中包含的页面的 url。我使用cookies实现了一个解决方法。这是我在 Sharepoint Stack Exchange 上的帖子: https://sharepoint.stackexchange.com/questions/33617/how-to-get-the-url-name-of-a-subsite-from-a-webpart啊,我也发现了另一个使用查询参数的解决方案,我在自己的答案中提到过。
This is the same problem I have had with the urls. You can use
Request.UrlReferrer.ToString()
in a page_load sub, but it only works when the page is first loaded. If you do a refresh then it gets the url of the page contained in the pageviewerwebpart instead. I implemented a workaround using cookies. Here is my post over at Sharepoint Stack Exchange: https://sharepoint.stackexchange.com/questions/33617/how-to-get-the-url-name-of-a-subsite-from-a-webpartAh, I also found another solution using query parameters, which I mention in my own answer.
尝试
Request.ServerVariables["HTTP_REFERER"]
。经过一番研究,我从Request.ServerVariables["HTTP_REFERER"]
获得了 url。问候,
阿贾伊·拉古万什
Try
Request.ServerVariables["HTTP_REFERER"]
. After bit of research I got the url fromRequest.ServerVariables["HTTP_REFERER"]
.Regards,
Ajay Raghuwanshi