XmlUrlResolver.Credentials XmlUrlResolver.Credentials XmlUrlResolver.Credentials XmlUrlResolver.Credentials Property

Definición

Establece las credenciales usadas para autenticar las solicitudes web.Sets credentials used to authenticate web requests.

public:
 virtual property System::Net::ICredentials ^ Credentials {  void set(System::Net::ICredentials ^ value); };
public override System.Net.ICredentials Credentials { set; }
member this.Credentials : System.Net.ICredentials
Public Overrides Property Credentials As ICredentials

Valor de propiedad

Credenciales que se usan para autenticar las solicitudes web.The credentials to be used to authenticate web requests. Si no se establece esta propiedad, el valor predeterminado es null; es decir, el objeto XmlUrlResolver no tiene credenciales de usuario.If this property is not set, the value defaults to null; that is, the XmlUrlResolver has no user credentials.

Ejemplos

En el ejemplo siguiente se XmlUrlResolver crea un objeto con credenciales.The following example creates an XmlUrlResolver object with credentials. Utiliza las credenciales XmlUrlResolver del objeto para tener acceso a un recurso de red. XmlReaderThe XmlReader uses the credentials on the XmlUrlResolver object to access a network resource.


// Create a resolver and specify the necessary credentials.
XmlUrlResolver resolver = new XmlUrlResolver();
System.Net.NetworkCredential myCred;
myCred  = new System.Net.NetworkCredential(UserName,SecurelyStoredPassword,Domain);  
resolver.Credentials = myCred;

    ' Create a resolver and specify the necessary credentials.
    Dim resolver As New XmlUrlResolver()
    Dim myCred As System.Net.NetworkCredential
    myCred = New System.Net.NetworkCredential(UserName, SecurelyStoredPassword, Domain)
    resolver.Credentials = myCred

Comentarios

Si el directorio virtual no requiere autenticación, no es necesario establecer esta propiedad.If the virtual directory does not require authentication, this property does not need to be set. De lo contrario, se deben proporcionar las credenciales del usuario.Otherwise, the credentials of the user must be supplied.

Puede asociar credenciales diferentes con diferentes URI y agregarlas a una memoria caché.You can associate different credentials with different URIs and add them to a cache. Después, puede usar las credenciales para comprobar la autenticación de los distintos URI, independientemente del origen original del XML.You can then use the credentials to check authentication for different URIs, regardless of the original source of the XML.

En el C# código siguiente se muestra cómo establecer Credentials la propiedad en una caché de credenciales.The following C# code shows how to set the Credentials property to a credential cache.

NetworkCredential myCred = new NetworkCredential(UserName,SecurelyStoredPassword,Domain);   
CredentialCache myCache = new CredentialCache();   
myCache.Add(new Uri("http://www.contoso.com/"), "Basic", myCred);   
myCache.Add(new Uri("http://app.contoso.com/"), "Basic", myCred);  
XmlUrlResolver resolver = new XmlUrlResolver();  
resolver.Credentials = myCache;  

Se aplica a

Consulte también: