WebRequestInformation.Principal 属性

定义

获取与 Web 请求关联的托管代码主体的实例。

public:
 property System::Security::Principal::IPrincipal ^ Principal { System::Security::Principal::IPrincipal ^ get(); };
public System.Security.Principal.IPrincipal Principal { get; }
member this.Principal : System.Security.Principal.IPrincipal
Public ReadOnly Property Principal As IPrincipal

属性值

IPrincipal

与请求事件关联的 IPrincipal 实例。

示例

下面的代码示例演示如何使用与 Web 请求关联的主体。

// Get the request principal.
public string GetRequestPrincipal()
{
    // Get the request principal.
    return (string.Format(
        "Request principal name: {0}",
        RequestInformation.Principal.Identity.Name));
}
' Get the request principal.
Public Function GetRequestPrincipal() As String
   ' Get the request principal.
     Return String.Format( _
     "Request principal name: {0}", _
     RequestInformation.Principal.Identity.Name)
End Function 'GetRequestPrincipal

注解

主体是指颁发 Web 请求的经过身份验证的实体。

适用于