WebRequest returns 401 Unauthorized

G

Guest

I'm trying to make a webrequest to another server on our webfarm (to synch
the cache as explained in http://www.eggheadcafe.com/articles/20030420.asp)
but I'm getting a 401 unauthorized error.

We are using service accounts for the app to run under which I thought would
work in setting the webrequest's credentials property but with no luck....

HttpWebRequest req = (System.Net.HttpWebRequest)WebRequest.Create(sFullUri);
req.Method = "POST";
Stream stm = req.GetRequestStream();
stm.Write(dataToSend,0,dataToSend.Length);
stm.Close();
System.Net.WebResponse resp;

string ServiceAcct =
System.Configuration.ConfigurationSettings.AppSettings["ServiceAcct"];
string ServiceAcctPwd =
System.Configuration.ConfigurationSettings.AppSettings["ServiceAcctPwd"];

NetworkCredential nc = new NetworkCredential(ServiceAcct, ServiceAcctPwd, "");
req.Credentials = nc;
resp = req.GetResponse(); <!--error below...

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

Bruce Barker

if your webservice is using ntlm, the service account needs to be a domain
account.

-- bruce (sqlwork.com)
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top