Skip to content

Instantly share code, notes, and snippets.

@krohrbaugh
Created December 16, 2008 15:48
Show Gist options
  • Save krohrbaugh/36637 to your computer and use it in GitHub Desktop.
Save krohrbaugh/36637 to your computer and use it in GitHub Desktop.
Example code block for authenticating .NET web services secured using HTTP Basic auth
/*
* Web service auth example
* - ReferencedWebService is the Web Reference service object
* and should be replaced with your actual service object
*/
ReferencedWebService webService = new ReferencedWebService();
webService.Url = "http://webservice.com/service.asmx";
webService.PreAuthenticate = true;
webService.Credentials = new System.Net.NetworkCredential("username", "password");
// Do web service calls here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment