How do I authenticate a user to consume a web service programmatically?
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 s开发者_如何学Co that I can consume the service? Or is there some other way I should be authenticating a user?
Try something like this:
YourWebReference webservice = new YourWebReference();
webservice.Credentials = new System.Net.NetworkCredential("username","password");
webservice.DoSomething();
精彩评论