Register Method
Collapse the table of content
Expand the table of content

AuthenticationManager.Register Method (IAuthenticationModule)


Registers an authentication module with the authentication manager.

Namespace:   System.Net
Assembly:  System (in System.dll)

public static void Register(
	IAuthenticationModule authenticationModule


Type: System.Net.IAuthenticationModule

The IAuthenticationModule to register with the authentication manager.

Exception Condition

authenticationModule is null.

The Register method adds authentication modules to the end of the list of modules called by the Authenticate method. Authentication modules are called in the order in which they were added to the list. If a module with the same AuthenticationType is already registered, this method removes the registered module and adds authenticationModule to the end of the list.

The following example registers an authentication module with the authentication manager. For a complete example, refer to the AuthenticationManager class.

// This is the program entry point. It allows the user to enter 
// her credentials and the Internet resource (Web page) to access.
// It also unregisters the standard and registers the customized basic 
// authentication.
public static void Main(string[] args) 

  if (args.Length < 3)

    // Read the user's credentials.
    uri = args[0];
    username = args[1];
    password = args[2];

    if (args.Length == 3)
      domain = string.Empty;
      // If the domain exists, store it. Usually the domain name
      // is by default the name of the server hosting the Internet
      // resource.
      domain = args[3];

    // Unregister the standard Basic authentication module.

    // Instantiate the custom Basic authentication module.
    CustomBasic customBasicModule = new CustomBasic();

    // Register the custom Basic authentication module.

    // Display registered Authorization modules.

    // Read the specified page and display it on the console.


for executing unmanaged code. Associated enumeration: SecurityPermissionFlag.

.NET Framework
Available since 1.1
Return to top
© 2016 Microsoft