Credentials Property
Collapse the table of content
Expand the table of content

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 Value

Type: System.Net.ICredentials
An ICredentials object. The XmlSecureResolver sets the given credentials on the underlying XmlResolver. If this property is not set, the value defaults to null; 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.


.NET Framework

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

.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

© 2016 Microsoft