473,499 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
+ 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.
Nov 17 '05 #1
3 4498
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]
Nov 17 '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]

Nov 17 '05 #3
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]

Nov 17 '05 #4

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

Similar topics

3
5210
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
8824
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
3439
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
3509
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
7006
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
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
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,...
0
4597
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
3096
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
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
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
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.