How to sets credentials used to authenticate Web requests

L

Li Pang

Hi,

I put a xml file in a web site "http://localhost/XML/default.xml", and I try
to open it from the following codes:

Dim doc As XmlDocument
doc = New XmlDocument()
doc.Load("http://localhost/XML/default.xml")

then I got an error: "(401) Unauthorized"

When I enabled anonymous access in "http://localhost/XML" site, then the
file can be opened successfully.

I'd like to know how to set credentials programmatically for this site and
keeping anonymous access disabled.

Thanks in advance
 
D

Dominick Baier [DevelopMentor]

Hello Li,

seems that XmlDocument does not support that. I would recommend opening the
file manually using HttpWebRequest or WebClient (both support a Credentials
property) and passing the stream to the ctor of XmlDocument.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top