How to sets credentials used to authenticate Web requests

Discussion in 'ASP .Net Security' started by Li Pang, Sep 13, 2005.

  1. Li Pang

    Li Pang Guest

    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
     
    Li Pang, Sep 13, 2005
    #1
    1. Advertising

  2. 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.

    ---------------------------------------
    Dominick Baier - DevelopMentor
    http://www.leastprivilege.com

    > 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
    >
     
    Dominick Baier [DevelopMentor], Sep 13, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fernando Arámburu

    web requests and mobile requests

    Fernando Arámburu, Apr 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    476
    Joerg Jooss
    Apr 8, 2005
  2. davout
    Replies:
    8
    Views:
    27,521
    josesuero
    Nov 12, 2010
  3. LamSoft
    Replies:
    1
    Views:
    2,080
    LamSoft
    Jul 24, 2007
  4. David Clegg

    Changing the Namespace URI used for incoming SOAP requests

    David Clegg, May 5, 2008, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    233
    David Clegg
    May 5, 2008
  5. Leo Violette
    Replies:
    0
    Views:
    1,108
    Leo Violette
    Apr 17, 2009
Loading...

Share This Page