简体   繁体   English

Sharepoint 2007:匿名用户如何计数,如果我将sessionstate更改为inproc,它会发生什么吗?

[英]Sharepoint 2007: how to do anonym users count, does it happen something if I change sessionstate to inproc?

I want to count the anonym users online in a Sharepoint 2007 website (in a farm). 我想在SharePoint 2010网站上(在服务器场中)在线统计匿名用户。

The classic way of doing this in .NET is: 在.NET中执行此操作的经典方法是:

   protected void Session_Start(object sender, EventArgs e)
    {
            Application.Lock();
            Application["online"] = Convert.ToInt16(Application["online"]) + 1;
            Application.UnLock();

    }

    protected void Session_End(object sender, EventArgs e)
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

        Application.Lock();
        Application["online"] = Convert.ToInt16(Application["online"]) - 1;
        Application.UnLock();

    }

You can't do this, if you are using a Sql server sessionstate, because Session_End does never fire, it fires only Session_Start. 如果使用的是Sql服务器sessionstate,则无法执行此操作,因为Session_End不会触发,因此只会触发Session_Start。

As you know, the web.config in Sharepoint Websites is configure with SQL server for sessions. 如您所知,Sharepoint网站中的web.config使用SQL Server配置用于会话。

<sessionState mode="SQLServer" timeout="1" allowCustomSqlDatabase="true" partitionResolverType="Microsoft.Office.Server.Administration.SqlSessionStateResolver, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

This is because you can share sessions between different servers as they are implemented in the SQL SERVER database. 这是因为您可以在SQL SERVER数据库中实现的不同服务器之间共享会话。 I don't care about this, because we are using a load balancer, so users keep the sessions thanks to this. 我不在乎,因为我们使用的是负载平衡器,因此用户可以保留会话。

So my first solution is to change the SessionState to "Inproc". 因此,我的第一个解决方案是将SessionState更改为“ Inproc”。 The user session will be kept in the same server thanks to the load balancer. 由于负载均衡器,用户会话将保留在同一服务器中。

But, second, I don't know if Application["online"] which is the property that will save the users online, will be shared between the different servers, or every server will have a different value if I use Inproc. 但是,第二,我不知道Application [“ online”]是可以将用户在线保存的属性,是否可以在不同服务器之间共享,或者如果我使用Inproc,每个服务器的值是否也不同。 This could be the real problem of changing to Sql Server sessionstate. 这可能是更改为Sql Server sessionstate的真正问题。

In summary: 综上所述:

1.- I need to know if Application is shared between servers even if inProc is in use in a Sharpoint farm. 1.-我需要知道即使在Sharpoint服务器场中使用了inProc,服务器之间是否也可以共享应用程序。

2.-Consequences/ problems / errors generated from changing to Inproc. 2.-因改用Inproc而产生的后果/问题/错误。

3.-Do you find any other solution to implement an anonym users' count if you have a sql server sessionstate and using Sharepoint 2007? 3.-如果您具有sql server sessionstate并使用Sharepoint 2007,您是否找到其他解决方案来实现匿名用户计数? I have found this solution using cache: http://www.codeproject.com/KB/aspnet/SessionEndStatePersister.aspx 我已经找到了使用缓存的解决方案: http : //www.codeproject.com/KB/aspnet/SessionEndStatePersister.aspx

The simplest, the best. 最简单,最好。

  1. The Application state is local to the server, regardless of how session state is handled. 无论如何处理会话状态,应用程序状态都是服务器本地的。

  2. If you use Inproc, you have to make sure that the load balancer keeps track of users, and always sends a sepcific user to the same server, or the session will be lost. 如果使用Inproc,则必须确保负载平衡器跟踪用户,并始终将另一个用户发送到同一服务器,否则会话将丢失。

  3. You can keep a local count of users per server, and periodically update a record in a table in the database with the count from each server. 您可以保留每台服务器的本地用户数,并使用每台服务器的计数定期更新数据库表中的记录。 You can then get the total number of users by summing up the count from all the rows in the table. 然后,您可以通过汇总表中所有行的计数来获得用户总数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在SessionState的超时计时器的[START]处如何做 - how do something at [START] of timeout timer in SessionState 当按下按钮而不是按住按钮时,如何让事情发生一次? - How do I make something happen ONCE when a button pressed but not WHILE it is held? 如何从sharepoint 2007中的自定义列表创建自定义Web部件 - How do I create a custom web part from a custom list in sharepoint 2007 如何通过C#获取SharePoint 2007列表中仅用户创建的字段列表? - How do I get a list of ONLY user-created fields in a SharePoint 2007 List via C#? 如何从SharePoint 2007中的用户控件调用webpart类文件中的方法? - How do I call a method that is in the webpart class file, from a usercontrol in SharePoint 2007? 如何编写自定义搜索页面以仅在SharePoint 2007中搜索当前网站和子网站? - How do I code a custom search page to search current site and sub-sites only in SharePoint 2007? 如何在SharePoint 2007中通过C#测试查找列表项,如果缺少,将其添加? - How do I test for a lookup list item, and add it if it is missing, in SharePoint 2007 via C#? 当表单X关闭时,我如何使某些事情发生在Y上 - when form X closes how do I make something happen to form Y 如何在Windows Phone 7应用中仅使一次事情发生? - How do I make something happen in my windows phone 7 app only once? 如何在运行时在SQLServer模式下为sessionState更改sqlConnectionString? - How to change sqlConnectionString for sessionState in SQLServer mode at runtime?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM