XmlSecureResolver.Credentials Property

Sets credentials used to authenticate Web requests.

Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)

public override ICredentials Credentials { set; }
/** @property */
public void set_Credentials (ICredentials value)

public override function set Credentials (value : ICredentials)

Property Value

An ICredentials object. The XmlSecureResolver sets the given credentials on the underlying XmlResolver. If this property is not set, the value defaults to a null reference (Nothing in Visual Basic); that is, the XmlSecureResolver has no user credentials.

The following example uses an XmlSecureResolver with default credentials to resolve/open network resources needed by the XmlTextReader.

using System;
using System.IO;
using System.Xml;
using System.Net;

public class Sample {

  public static void Main() {

    // Create the reader.
    XmlTextReader reader = new XmlTextReader("http://myServer/data/books.xml");
    // Create a secure resolver with default credentials.
    XmlUrlResolver resolver = new XmlUrlResolver();
    XmlSecureResolver sResolver = new XmlSecureResolver(resolver, "http://myServer/data/");
    sResolver.Credentials = CredentialCache.DefaultCredentials;

    // Use the secure resolver to resolve resources.
    reader.XmlResolver = sResolver;

    // Parse the file.
    while (reader.Read()) {
       // Do any additional processing here.
    // Close the reader.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1

Community Additions