XmlSecureResolver.Credentials Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Property Value
The credentials to be used to authenticate web requests. 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.
Examples
The following example uses an XmlSecureResolver with default credentials to resolve and open network resources needed by the XmlTextReader.
#using <System.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
using namespace System::Net;
int main()
{
// Create the reader.
XmlTextReader^ reader = gcnew XmlTextReader( "http://myServer/data/books.xml" );
// Create a secure resolver with default credentials.
XmlUrlResolver^ resolver = gcnew XmlUrlResolver;
XmlSecureResolver^ sResolver = gcnew 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.
reader->Close();
}
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.
reader.Close();
}
}
Imports System.IO
Imports System.Xml
Imports System.Net
public class Sample
public shared sub Main()
' Create the reader.
Dim reader as XmlTextReader = new XmlTextReader("http://myServer/data/books.xml")
' Create a secure resolver with default credentials.
Dim resolver as XmlUrlResolver = new XmlUrlResolver()
Dim sResolver as XmlSecureResolver = 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.
end while
' Close the reader.
reader.Close()
end sub
end class
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET