(401) Unauthorized on subsequent requests?

D

Dave

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();
 

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,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top