The request failed with HTTP status 401: Unauthorized

M

manika02

Hi,
I get the following eror when I try to call my WebService (on the local
machine) using another Web application (on the local machine)

System.Net.WebException: The request failed with HTTP status 401: Unauthorized

Any insights on this would be helpful.

Thanks
 
S

Scott M.

The web service you are attempting to access requires that the caller
provide its credentials to prove that it should be allowed to access the web
service. You can use this code to send the "default credentials" to the web
service:

Dim myProxy As New localhost.Service1()
myProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
 
J

Josh Twist

Also, If you're not interested in using Windows Authentication in IIS
to secure your web service you can just turn Anonymous Authentication
on for your web service's Virtual Directory:

- Right click on the virtual directory in IIS
- Choose properties from the context menu
- Select the Directory Security Tab
- Click the Edit button in the Anonymous access and authentication
control
- Check the anonymous access box
 
B

BigJohn

I am getting the same problem running on Windows XP Pro with the anonymous
auth.
 
B

BigJohn

I tried this method and Josh's (set web service with anonymous auth) and
cannot bet either to funtion. I am running on Windows XP Pro, all modules
are within same solution.
 
G

geyser hi

It works for me (c#). Thanks a lot.

localhost.Service1 ws=new localhost.Service1();
ws.Credentials = System.Net.CredentialCache.DefaultCredentials ;
textBox1.Text=ws.HelloWorld();
 
G

geyser hi

Thanks. The code works for me (C#)

localhost.Service1 ws=new localhost.Service1();
ws.Credentials = System.Net.CredentialCache.DefaultCredentials ;

textBox1.Text=ws.HelloWorld();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top