HttpListener.Realm 属性
定义
获取或设置与此 HttpListener 对象关联的领域或资源分区。Gets or sets the realm, or resource partition, associated with this HttpListener object.
public:
property System::String ^ Realm { System::String ^ get(); void set(System::String ^ value); };
public string? Realm { get; set; }
public string Realm { get; set; }
member this.Realm : string with get, set
Public Property Realm As String
属性值
String 值,包含与 HttpListener 对象关联的领域名。A String value that contains the name of the realm associated with the HttpListener object.
例外
此对象已关闭。This object has been closed.
示例
下面的代码示例演示如何设置 Realm 属性。The following code example demonstrates setting the Realm property.
public static void ConfigureListener1(HttpListener listener)
{
// Specify an authentication realm.
listener.Realm = "ExampleRealm";
}
Public Shared Sub ConfigureListener1(ByVal listener As HttpListener)
' Specify an authentication realm.
listener.Realm = "ExampleRealm"
End Sub
注解
服务器使用领域来对受保护的资源进行分区;每个分区都可以有自己的身份验证方案和/或授权数据库。Servers use realms to partition protected resources; each partition can have its own authentication scheme and/or authorization database. 领域仅用于基本和摘要式身份验证。Realms are used only for basic and digest authentication. 在客户端成功进行身份验证之后,该身份验证对给定领域内的所有资源都有效。After a client successfully authenticates, the authentication is valid for all resources in a given realm. 有关领域的详细说明,请参阅 RFC 2617,网址为 https://www.ietf.org/ 。For a detailed description of realms, see RFC 2617 at https://www.ietf.org/.
的实例 HttpListener 只具有一个关联的领域。An instance of HttpListener has only one associated realm.