SocketTools .NET Edition

HttpServer.RequireAuthentication Method (String)

Send a response to the client indicating that authentication is required.

[Visual Basic]
Overloads Public Function RequireAuthentication( _
   ByVal realm As String _
) As Boolean
[C#]
public bool RequireAuthentication(
   string realm
);

Parameters

realm
A string value that is displayed a web browser to indicate to the user which username and password they should use. If this parameter is omitted or is an empty string, the domain name the client used to establish the connection will be used.

Return Value

A boolean value which specifies if the response was sent to the client. A return value of true specifies that the operation was successful. If an error occurs, the method returns false and the application should check the value of the LastError property to determine the cause of the failure

Remarks

The RequireAuthentication method can be used within an OnCommand event handler to indicate to the client that it must provide a username and password to access the requested resource. The client should respond by issuing another request that includes the required credentials. To determine if a client has included valid credentials with its request, check the value of the IsAuthenticated property.

Some clients may require that the session be secure if authentication is requested or display warning messages to the user if the connection is not secure. If your application will require clients to authenticate before accessing specific resources, it is recommended that you enable security by setting the Secure property to True prior to starting the server.

This version of the method uses the active client session and should only be called from within a server event handler. To specify a client session outside of an event handler, use the version of this method that accepts a client ID parameter.

See Also

HttpServer Class | SocketTools Namespace | HttpServer.RequireAuthentication Overload List