ASP.NET | Аутентификация Форм | Добирается, ВСЕ вошли в систему пользователи (список всех пользователей или количества)

Да, существует несколько способов применить шаблон единицы работы для MongoDB в зависимости от версии базы данных.

До MongoDB 4.0 не было поддержки транзакций ACID с несколькими документами. Затем разработчики использовали «протокол двухфазного принятия» (единая база данных) и «протокол трехфазного принятия» (неблокирование в распределенных базах данных) для создания собственного уровня транзакций, который обеспечивал согласованность данных , но не выполнение «все или ничего» для сохранения целостности данных. Таким образом, это снизило производительность.

В MongoDB 4.0 добавлена ​​поддержка многодокументных транзакций ACID.

Источники:

https://en.wikipedia.org/wiki/Two-phase_commit_protocol

https://en.wikipedia.org / wiki / Three-phase_commit_protocol

https://www.mongodb.com/transactions

8
задан Chicago 30 October 2009 в 13:41
поделиться

4 ответа

No there isn't unless

  1. You have defined one in your own code

  2. You are using the default ASPNET Membership Provider which has a GetNumberOfUsersOnline() method defined.

  3. You are using a custom Membership Provider and have provided an implementation for the GetNumberOfUsersOnline() method yourself

The default ASPNET Membership provider calculates number of users online by querying the SQL Server database and checking the LastActivityDate stored against each user against the defined UserIsOnlineTimeWindow property that you can set in web.config. If the LastActivityDate is greater than the current time minus the UserIsOnlineTimeWindow value (which represents minutes), then a user is considered to be online.

If you wanted to do something similar then you might consider implementing a similar method. you can see the code for the default providers by downloading the source code. To complete your picture, you might also want to run aspnet_regsql.exe so that you can see the stored procedures that the default providers use.

6
ответ дан 5 December 2019 в 12:10
поделиться

У поставщика членства есть свои преимущества, но чтобы отслеживать пользователей в сети, вы также можете:

  1. Добавить столбец LastActivityDate в свою таблицу пользователей и обновить его из своего кода во время входа в систему и при загрузке всех страниц для этого пользователя.

  2. И чтобы получить пользователей в сети за последние X минут, просто используйте следующий sql

     Выберите * из пользователей, где LastActivityDate>
    DATEADD (минута; - (X); GETDATE ()) 
    
4
ответ дан 5 December 2019 в 12:10
поделиться

Forms Authentication stored all it’s state in a cookie that is passed to the users browsers.

(This enables Forms Authentication to work on a web farm)

Therefore there is no way to get a list of logged users etc from standard Forms Authentication.

However Forms Authentication has events that it fires when it Authenticates a user etc. You could update your own list of users in these events – (be careful with locking if you do so)

However as a user will be “logged of” when the cookie is expired by the browsers, you will find it very hard to correctly remove all logged of users at the correct time from your list.


You may be better of stored the time you last saw each users and then having a list of users you have seen in say the last 5 minutes. E.g keep a list of active users.

3
ответ дан 5 December 2019 в 12:10
поделиться

I used Session_Start and Session_End under Global.aspx. it works most of times except the user close his/her browser. the server side needs to wait for the session expired to remove the user.

1
ответ дан 5 December 2019 в 12:10
поделиться
Другие вопросы по тегам:

Похожие вопросы: