views:

42

answers:

1

I have a web service set up on an IIS server. When I navigate to the page in a web browser it asks me for my user name an password, as desired. However I want to consume the service in a .NET application (C#). What do I need to do to provide a user name and password programmatically so that I can consume the service? Or is there some other way I should be authenticating a user?

+1  A: 

Try something like this:

YourWebReference webservice = new YourWebReference();
webservice.Credentials = new System.Net.NetworkCredential("username","password");
webservice.DoSomething();
Rubens Farias
Field is read only... I used the visual studio service reference wizard, so maybe there's more i'm missing.
MGSoto