473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 12474
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
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
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
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
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
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
by: obeOnline | last post by:
I'm getting the following error... System.Net.HttpWebRequest.CheckFinalStatus() +676 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +139...
0
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
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
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
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.