I have the following line in a Controller
ViewData["UsersOnLineNow"] = Membership.GetNumbe开发者_如何转开发rOfUsersOnline().ToString();
I am logged in as an Administrator but the above is returning a value of 0, verified by QickWatch. I was expecting a value of 1.
I also have the following in the Controller
ViewData["RegisteredUsers"] = Membership.GetAllUsers().Count.ToString();
This is returning the correct value of 2, myself included.
Anyone else had problems in this area?
MSDN:
GetNumberOfUsersOnline returns the number of users for the current ApplicationName where the last-activity date is greater than the current time less the UserIsOnlineTimeWindow. The last-activity date/time stamp is updated to the current date and time when user credentials are validated by way of the ValidateUser or UpdateUser method or when a call to a GetUser overload that takes no parameters or one that uses the userIsOnline parameter to specify that the date/time stamp should be updated.
Tip: You can try setting your UserIsOnlineTimeWindow to a higher value. Default value is 15 minutes, in the following example I've set it to 60.
<membership defaultProvider="AspNetSqlMembershipProvider"
userIsOnlineTimeWindow="60">
<providers>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
精彩评论