public abstract class XmlResolver
|
XmlUrlResolver is the default resolver for all classes in the System.Xml namespace. However, you can also create your own resolver. For more information on implementing your own resolver, see the conceptual topic at MSDN: creatingcustomresolver.
Credentials | Write-only When overridden in a derived class, sets the credentials used to authenticate Web requests. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetEntity | When overridden in a derived class, maps a URI to an object containing the actual resource. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ResolveUri | When overridden in a derived class, resolves the absolute URI from the base and relative URIs. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
protected XmlResolver(); |
ICredentials Credentials {set;}
|
The following C# code sets credentials for the virtual directory "http://localhost/bookstore/inventory.xml"
XmlTextReader reader = new XmlTextReader("http://localhost/bookstore/inventory.xml"); NetworkCredential nc = new NetWorkCredential("username", "password", "domain"); XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials = nc; reader.XmlResolver= resolver;
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","password","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; reader.XmlResolver = resolver;
~XmlResolver(); |
absoluteUri
role
ofObjectToReturn
Exception Type | Condition |
---|---|
XmlException | There is a runtime error (for example, an interrupted server connection). |
UriFormatException | The specified URI is not an absolute URI. |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
baseUri
relativeUri
Exception Type | Condition |
---|---|
UriFormatException | The supplied URIs are not absolute. |
public virtual string ToString(); |