คุณสมบัติ WebSecurity CurrentUserName
คำจำกัดความ
คุณสมบัติ CurrentUserName เป็นชื่อของผู้ใช้ปัจจุบันในโปรไฟล์ผู้ใช้ตารางฐานข้อมูล WebSecurity ที่
C # และไวยากรณ์ VB
WebSecurity.CurrentUserName
ตัวอย่าง
ตัวอย่างของ C #
@{
string value;
value=WebSecurity.CurrentUserId;
}
<p>Welcome @value</p>
string value;
value=WebSecurity.CurrentUserId;
}
<p>Welcome @value</p>
ตัวอย่าง VB
@Code
Dim value as String
value=WebSecurity.CurrentUserName
End Code
<p>Welcome @value</p>
Dim value as String
value=WebSecurity.CurrentUserName
End Code
<p>Welcome @value</p>
คำพูด
คุณสมบัติ CurrentUserName อ่านอย่างเดียว มันไม่สามารถเปลี่ยนรหัส
ข้อผิดพลาดและข้อยกเว้น
ในสถานการณ์สมมติต่อการเข้าถึงใด ๆ ไปยังวัตถุ WebSecurity จะโยน InvalidOperationException:
- InitializeDatabaseConnection () วิธีการยังไม่ได้รับการเรียกว่า
- SimpleMembership ไม่ได้เริ่มต้น (หรือคนพิการในการกำหนดค่าเว็บไซต์)
ข้อมูลทางเทคนิค
名称 | 值 |
---|---|
Namespace | WebMatrix.WebData |
Assembly | WebMatrix.WebData.dll |
วัตถุ WebSecurity