HttpListener.Realm Property

Definition

Gets or sets the realm, or resource partition, associated with this HttpListener object.

C#
public string? Realm { get; set; }
C#
public string Realm { get; set; }

Property Value

A String value that contains the name of the realm associated with the HttpListener object.

Exceptions

This object has been closed.

Examples

The following code example demonstrates setting the Realm property.

C#
public static void ConfigureListener1(HttpListener listener)
{
    // Specify an authentication realm.
    listener.Realm = "ExampleRealm";
}

Remarks

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. For a detailed description of realms, see RFC 2617 at https://www.ietf.org/.

An instance of HttpListener has only one associated realm.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1