473,513 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebRequest returns 401 Unauthorized

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(sFull Uri);
req.Method = "POST";
Stream stm = req.GetRequestStream();
stm.Write(dataToSend,0,dataToSend.Length);
stm.Close();
System.Net.WebResponse resp;

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

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

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

Nov 19 '05 #1
1 3150
if your webservice is using ntlm, the service account needs to be a domain
account.

-- bruce (sqlwork.com)
"Dave" <Da**@discussions.microsoft.com> wrote in message
news:A8**********************************@microsof t.com...
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(sFull Uri);
req.Method = "POST";
Stream stm = req.GetRequestStream();
stm.Write(dataToSend,0,dataToSend.Length);
stm.Close();
System.Net.WebResponse resp;

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

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

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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
7217
by: James Johnson | last post by:
Dear C#dex, I define a variable: HttpWebRequest webRequest and run the following request webRequest = WebRequest.Create(TARGET_URL) as HttpWebRequest; The webRequest object returns values...
2
9685
by: gizmo | last post by:
Hi, I'm using the following code to request the html source from the quoted site. ...... string url = "http://www1.soccerstand.com/"; WebRequest webRequest = WebRequest.Create(url);...
5
376
by: LOLO | last post by:
I want to save in a file the HTML code generated by a WebRequest to an aspx page. When a connect to a external site, i can obtain the html code generated by server. But when i connect to a page of...
4
7217
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server...
2
8194
by: obeOnline | last post by:
I'm getting the following error... System.Net.HttpWebRequest.CheckFinalStatus() +676 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +139...
0
1269
by: z. f. | last post by:
Hi, i have asp.net vb.net wep application. i try to investigate performance issue. so first i built a vb.net windows application that makes http requests to my pages and show me the time taken...
12
2848
by: ThyRock | last post by:
I am working on a WebRequest accessing the US Postal Service WebTools test API. This service uses a DLL file (ShippingAPITest.dll) with a query string which includes XML. The web service accepts...
0
931
by: KSC | last post by:
Hello, I am trying to access an ethernet temperature probe in my app. The probe is properly configured. Using IE I can access the data using the IPaddress & "/temp". This returns a string...
0
1196
by: tascien | last post by:
Hi guys, when i use winhttp, and the server returns status 500, I get the text that the server returned anyway... when i use webrequest, and the server returns status 500, webrequest just...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.