Latest web development tutorials

Obiekt WebSecurity CurrentUserId

obiekty WebSecurity obiekty WebSecurity

definicje

atrybut CurrentUserId jest aktualny identyfikator użytkownika (klucz podstawowy) w bazie WebSecurity.


C # i VB składni

WebSecurity.CurrentUserId


Przykłady

Przykłady C #

@{
int value;
value=WebSecurity.CurrentUserId;
}

<p>Current User ID is: @value</p>

Przykłady VB

@Code
Dim value as Integer
value=WebSecurity.CurrentUserId
End Code

<p>Current User ID is: @value</p>


uwaga

Obiekt CurrentUserId jest tylko do odczytu. Nie można zmienić kodu.

Ten atrybut jest używany do identyfikacji użytkowników w tabeli bazy danych członków WebSecurity i użytkowników w tabeli.


Błędy i wyjątki

Jeśli żaden użytkownik jest aktualnie zalogowany, CurrentUserId zwrotu własności -1.

W poniższym scenariuszu, każdy dostęp do obiektu WebSecurity rzuci InvalidOperationException:

  • Metoda InitializeDatabaseConnection () nie została wywołana
  • Nie SimpleMembership inicjowane (lub wyłączone w konfiguracji stronie)

dane techniczne

名称
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll


obiekty WebSecurity obiekty WebSecurity