When overridden in a derived class, sets the credentials used to authenticate Web requests.
Assembly: System.Xml (in System.Xml.dll)
If the virtual directory does not require authentication, this property does not need to be set. Otherwise, the credentials of the user must be supplied.
The following C# code sets credentials on the XmlResolver object.
NetworkCredential nc = new NetWorkCredential(UserName,SecurelyStoredPassword,Domain); XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials = nc;
Different credentials can be associated with different URIs and added to a credential cache. The credentials can then be used to check authentication for different URIs regardless of the original source of the XML.
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;
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.