473,624 Members | 2,612 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.ourcom pany.com:8010/Page1";
WebRequest wreq = WebRequest.Crea te(url);
//Assign the default logon creadentials.
wreq.Credential s = CredentialCache .DefaultCredent ials;
wreq.Timeout = 1000;
//Get the web response stream
WebResponse wres = wreq.GetRespons e();
----
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 4505
This is because the CredentialCache .DefaultCredent ials uses your Windows credentials for authenication which the JBoss server doesn't know anything about

Create a new instance of the System.Net.Netw orkCredentials 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.ourcom pany.com:8010/Page1";
WebRequest wreq = WebRequest.Crea te(url);
//Assign the default logon creadentials.
wreq.Credential s = CredentialCache .DefaultCredent ials;
wreq.Timeout = 1000;
//Get the web response stream
WebResponse wres = wreq.GetRespons e();
----
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.publi c.dotnet.langua ges.csharp]
Nov 17 '05 #2
hello
"Richard Blewett [DevelopMentor]" <ri******@NOSPA Mdevelop.com> wrote in
message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
This is because the CredentialCache .DefaultCredent ials uses your Windows credentials for authenication which the JBoss server doesn't know anything
about
Create a new instance of the System.Net.Netw orkCredentials 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.ourcom pany.com:8010/Page1";
WebRequest wreq = WebRequest.Crea te(url);
//Assign the default logon creadentials.
wreq.Credential s = CredentialCache .DefaultCredent ials;
wreq.Timeout = 1000;
//Get the web response stream
WebResponse wres = wreq.GetRespons e();
----
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.publi c.dotnet.langua ges.csharp]

Nov 17 '05 #3
hello
"Richard Blewett [DevelopMentor]" <ri******@NOSPA Mdevelop.com> wrote in
message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
This is because the CredentialCache .DefaultCredent ials uses your Windows credentials for authenication which the JBoss server doesn't know anything
about
Create a new instance of the System.Net.Netw orkCredentials 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.ourcom pany.com:8010/Page1";
WebRequest wreq = WebRequest.Crea te(url);
//Assign the default logon creadentials.
wreq.Credential s = CredentialCache .DefaultCredent ials;
wreq.Timeout = 1000;
//Get the web response stream
WebResponse wres = wreq.GetRespons e();
----
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.publi c.dotnet.langua ges.csharp]

Nov 17 '05 #4

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

Similar topics

3
5225
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 Windows 2000 domain (mixed-mode): MYDOMAIN (mydomain.net) Windows 2003 Server w/IIS6: WEB01 Windows 2000 Server hosting files: FILE01 Windows XP Pro client workstation: CLIENT01
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 I am trying to logon to remote server thru my code. when i paste the link in web browser it is working correctly but when iam trying to execute thru my code it is giving me problem saying ur Unauthorized. Here is my code:
0
1806
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 retrieve the xml using the xml web control, I get this error: The remote server returned an error: (401) Unauthorized. Am I doing something wrong? Below is the function that I created to read the xml: Private Sub Page_Load(ByVal sender As...
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) Unauthorized." I am attempting to access a secure https site which 1-the site gives you your own certificate to use to access the site 2-a uname/password challenge i am not sure if it is basic or digest but i
3
2116
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 Sub DoStuff() Dim sURL As String Dim XMLnews As XmlDocument = New XmlDocument Dim XMLroot As System.Xml.XmlElement
2
8199
by: obeOnline | last post by:
I'm getting the following error... System.Net.HttpWebRequest.CheckFinalStatus() +676 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +139 System.Net.HttpWebRequest.GetResponse() +147 Web.WebDav.Page_Load(Object sender, EventArgs e)
0
8832
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. My web server has both NTLM and Basic authentication. By providing the Credentials for my web service call, my application can access the web service without any problems. The problem: I recently created a new application with Visual Studio...
5
3466
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 The remote server returned an error: (401) Unauthorized.
0
1890
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 dictionary to A folder. And IIS has allowed annoymous access. But when I use following code to access the webpage and I got the error" The
0
3532
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 xml data. but if i used this url in code means i send Requset and post data on server then i am getting Error(The remote server returned an error: (401) Unauthorized.) here i used same credentials. I send request by this code. HttpWebRequest...
0
8246
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8631
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2612
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 we have to send another system
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1489
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.