473,480 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

The remote server returned an error: (401) Unauthorized

Hi,

I am using the following C# code to connect to and download information from
a URL. (The pages are on JBoss server and we are using NTLM authentication
to connect to the server).

----
string url = "http://internal.ourcompany.com:8010/Page1";
WebRequest wreq = WebRequest.Create(url);
//Assign the default logon creadentials.
wreq.Credentials = CredentialCache.DefaultCredentials;
wreq.Timeout = 1000;
//Get the web response stream
WebResponse wres = wreq.GetResponse();
----
For some users, this code throws an error saying "The remote server returned
an error: (401) Unauthorized". When the user directly accesses the URL using
IE, he is able to see the information correctly.
Could someone help me out what is causing this error?

Thanks in advance,
Vijaya Krishna P.
Aug 22 '05 #1
2 12487
This is because the CredentialCache.DefaultCredentials uses your Windows credentials for authenication which the JBoss server doesn't know anything about

Create a new instance of the System.Net.NetworkCredentials class (it takes a user id, password and domain) and set the credentials of the web service proxy to that.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Hi,

I am using the following C# code to connect to and download information from
a URL. (The pages are on JBoss server and we are using NTLM authentication
to connect to the server).

----
string url = "http://internal.ourcompany.com:8010/Page1";
WebRequest wreq = WebRequest.Create(url);
//Assign the default logon creadentials.
wreq.Credentials = CredentialCache.DefaultCredentials;
wreq.Timeout = 1000;
//Get the web response stream
WebResponse wres = wreq.GetResponse();
----
For some users, this code throws an error saying "The remote server returned
an error: (401) Unauthorized". When the user directly accesses the URL using
IE, he is able to see the information correctly.
Could someone help me out what is causing this error?

Thanks in advance,
Vijaya Krishna P.

[microsoft.public.dotnet.languages.csharp]
Aug 22 '05 #2
hello
"Richard Blewett [DevelopMentor]" <ri******@NOSPAMdevelop.com> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
This is because the CredentialCache.DefaultCredentials uses your Windows credentials for authenication which the JBoss server doesn't know anything
about
Create a new instance of the System.Net.NetworkCredentials class (it takes a user id, password and domain) and set the credentials of the web
service proxy to that.
Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Hi,

I am using the following C# code to connect to and download information from a URL. (The pages are on JBoss server and we are using NTLM authentication to connect to the server).

----
string url = "http://internal.ourcompany.com:8010/Page1";
WebRequest wreq = WebRequest.Create(url);
//Assign the default logon creadentials.
wreq.Credentials = CredentialCache.DefaultCredentials;
wreq.Timeout = 1000;
//Get the web response stream
WebResponse wres = wreq.GetResponse();
----
For some users, this code throws an error saying "The remote server returned an error: (401) Unauthorized". When the user directly accesses the URL using IE, he is able to see the information correctly.
Could someone help me out what is causing this error?

Thanks in advance,
Vijaya Krishna P.

[microsoft.public.dotnet.languages.csharp]

Aug 22 '05 #3

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

Similar topics

3
5208
by: Jacob | last post by:
Hello All, I am trying to serve out some content via IIS that is hosted on a remote fileserver, and am unable to get the delegation working correctly. Our setup is as follows: Local LAN...
0
580
by: sirumalla | last post by:
These posting i have seen in so many sites but none of them solved the problem. Iam trying to fix this problem past 2 days but iam not able to do so. I doubt whether iam missing any peice of code ...
0
1788
by: Jason | last post by:
I am trying to retrieve XML data from an ASP page. If I type the URL to the asp page into my browser (i.e. http://domain.com/getxml.asp) , I will get the xml displayed in IE. But, if I try to...
1
875
by: Leonard Danao | last post by:
I get this error when i run my code below "An unhandled exception of type 'System.Net.WebException' occurred in system.dll Additional information: The remote server returned an error: (401)...
3
2110
by: Paul | last post by:
Hi, This is driving me crazy. I have a solution that works great on one site, but doesn't on another site. Same exact code on two different windows environments. Here is the code: Private...
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
8822
by: Kris Mattheus | last post by:
A little background: I've been using web services successfully for a while now. My web server is a Windows CE 4.2 device and my client is a windows C# application created with Visual Studio 2003....
5
3438
by: johnlim20088 | last post by:
Hi SOMEONE PLEASE HELP ME I have a vb net program to call localhost http://localhost/hi.aspx, my page work FINE when I browse it, but when I call it through vb net program it return error ...
0
1875
by: =?Utf-8?B?R2VvcmdlIFNodWk=?= | last post by:
I have a folder structure such like this. A ---A1 -----a1.aspx ---A2 A1 and A2 are the subfolder of A. And under the A1 folder, it contains one aspx file named a1.aspx. I set the IIS virtual...
0
3508
by: nidhisahu | last post by:
Hello All, i am open this URL( http://id.skootit.com/WorkspaceService/ListInvitations?actor=http://goku.id.skootit.com/) directly in browser with enter credential then its open and show...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7044
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
6739
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
5337
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
4779
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
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1300
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
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
181
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.