(401) Unauthorized on subsequent requests?

Discussion in 'ASP .Net Web Services' started by Dave, May 4, 2004.

  1. Dave

    Dave Guest

    Hi, I'm trying to make a call to url using the code below. The url points to XML files in a virtual folder (under basic auth) my dev server and returns XML to my local machine OK. But when I run this code on the same server as where the url points to, it works once then returns on repeated requests..

    "The remote server returned an error: (401) Unauthorized.

    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://mydevserv:1027/Secure/Reports/14330.XML")
    HttpContext cxt = HttpContext.Current
    NetworkCredential nc = new NetworkCredential(cxt.Request.ServerVariables["AUTH_USER"], cxt.Request.ServerVariables["AUTH_PASSWORD"],"")
    req.Credentials = nc
    WebResponse resp = req.GetResponse(); <--ERRO
    StreamReader sr = new StreamReader(resp.GetResponseStream())
    string strStream = sr.ReadToEnd();
     
    Dave, May 4, 2004
    #1
    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. Vijayakrishna Pondala

    The remote server returned an error: (401) Unauthorized

    Vijayakrishna Pondala, Aug 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    28,070
    William C.
    Aug 22, 2005
  2. Lloyd Dupont
    Replies:
    0
    Views:
    4,464
    Lloyd Dupont
    Apr 16, 2004
  3. =?Utf-8?B?RGF2ZQ==?=

    WebRequests & 401 Unauthorized errors

    =?Utf-8?B?RGF2ZQ==?=, May 5, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    419
    =?Utf-8?B?RGF2ZQ==?=
    May 5, 2004
  4. Jeevan
    Replies:
    0
    Views:
    435
    Jeevan
    Jan 20, 2006
  5. tlang
    Replies:
    4
    Views:
    130
    Diego Vilar
    Mar 13, 2005
Loading...

Share This Page