First, in Reference.cs, add the following command into the class of the Web Services that is referenced.
[C#]
this.PreAuthenticate = true;
this.Credentials = System.Net.CredentialCache.DefaultCredentials;
this.PreAuthenticate = true;
this.Credentials = System.Net.CredentialCache.DefaultCredentials;
However, the senior colleague at my office told me that this method mostly works with VB.Net but not C#. So he recommended me to try the second method by set it as the Network Credential by assigning the username and password. (So, this one will okay when you have the username and password for the server that you call the web services)
[C#]
this.Credentials = new System.Net.NetworkCredential("username", "password");
this.Credentials = new System.Net.NetworkCredential("username", "password");
No comments:
Post a Comment