I am trying to read a secure XML document from a URI in C#. I understand the basics of the XmlReader class. However I cannot figure out how to supply a username and password for the URI in code. I get the feeling it has something to do with an XmlSecureResolver object. But I can't figure out how to set the username and password. Can anyone help me with how to set the credentials?
Thanks, Corey
I think this should do the trick:
WebRequest request = WebRequest.Create(url);
request.Credentials = new NetworkCredential("usernamne", "password");
using (WebResponse response = request.GetResponse())
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
// Blah blah...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With