是否有必要设置NetworkCredential域?

时间:2015-11-16 13:20:48

标签: c# .net web-services

访问网络服务时是否需要设置networkCredential域?

var service = new service1.SoapEx();
service.Credentials = new NetworkCredential("user", "password", "domain");

或者我能做到:

 var service = new service1.SoapEx();
 service.Credentials = new NetworkCredential("user", "password");

由于

1 个答案:

答案 0 :(得分:3)

不,它没有必要,因为NetworkCredential类的功能与第二个示例类似。请记住,密码参数只接受SecureString,而不接受String。