Export (0) Print
Expand All

AuthenticationManager.Unregister Method (IAuthenticationModule)

Removes the specified authentication module from the list of registered modules.

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

public static void Unregister(
	IAuthenticationModule authenticationModule
)

Parameters

authenticationModule
Type: System.Net.IAuthenticationModule
The IAuthenticationModule to remove from the list of registered modules.

ExceptionCondition
ArgumentNullException

authenticationModule is null.

InvalidOperationException

The specified IAuthenticationModule is not registered.

The Unregister method removes the specified authentication module from the list of authentication modules called by the Authenticate method. The module must have been added to the list using the Register method before it can be removed from the list.

The following example uses the Unregister method to remove the specified authentication module from the list of registered modules. 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)
    showusage();
  else 
  {    

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

    if (args.Length == 3)
      domain = string.Empty;
    else
      // 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.
    AuthenticationManager.Unregister("Basic");

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

    // Register the custom Basic authentication module.
    AuthenticationManager.Register(customBasicModule);

    // Display registered Authorization modules.
    displayRegisteredModules();

    // Read the specified page and display it on the console.
    getPage(uri);
  }
  return;
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft