The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
NetworkCredential Constructor (String^, String^)
.NET Framework (current version)
Initializes a new instance of the NetworkCredential class with the specified user name and password.
Assembly: System (in System.dll)
Parameters
- userName
-
Type:
System::String^
The user name associated with the credentials.
- password
-
Type:
System::String^
The password for the user name associated with the credentials.
The constructor initializes a NetworkCredential object with the UserName property set to userName and the Password property set to password.
The following code example creates a NetworkCredential object using the specified user name and password.
// Call the onstructor to create an instance of NetworkCredential with the // specified user name and password. NetworkCredential^ myCredentials = gcnew NetworkCredential( username,passwd ); // Create a WebRequest with the specified URL. WebRequest^ myWebRequest = WebRequest::Create( url ); myCredentials->Domain = domain; myWebRequest->Credentials = myCredentials; Console::WriteLine( "\n\nCredentials Domain : {0} , UserName : {1} , Password : {2}", myCredentials->Domain, myCredentials->UserName, myCredentials->Password ); Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response..." ); // Send the request and wait for a response. WebResponse^ myWebResponse = myWebRequest->GetResponse(); // Process the response. Console::WriteLine( "\nResponse received successfully." ); // Release the resources of the response object. myWebResponse->Close();
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: