|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Web Service authentication
Hello
I have Web Service with two functions: [Webmethod] public string WinAuthHelloWorld() { return "WA : Hello world" } [Webmethod] public string BasicAuthHelloWorld() { return "BA : Hello world" } In IIS I turn on the checkboxes "Integrated windows authentication" and "Basic Authentication". In my client application I wrote: // Main is static static void Main() { Console.Write(CallBasicAuthHelloWorld()); Console.WriteCallWinAuthHelloWorld()); } private string CallBasicAuthHelloWorld() { NetworkCredential netCredential = new NetworkCredential("domainname\username", "password"); Uri uri = new Uri(service.Url); ICredentials credentials = netCredential.GetCredential(uri, "Basic"); service.Credentials = credentials; service.PreAuthenticate = true; return service.BasicAuthHelloWorld(); } private string CallWinAuthHelloWorld() { Uri uri = new Uri(service.Url); service.Credentials = = System.Net.CredentialCache.DefaultCredentials; return WinAuthHelloWorld(); } In invocation BasicAuthHelloWorld function I got Error 401 : Unauthorized. What I dismiss in my code? Thanks |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Web Service authentication |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|