WCF设置在ClientCredentials的App.config [英] Set WCF ClientCredentials in App.config

查看:393
本文介绍了WCF设置在ClientCredentials的App.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能设置clientcredentials在App.config中的WCF?

Is it possible to set clientcredentials for an WCF in App.config?

我想避免这样做:

Using svc As New MyServiceClient
  svc.ClientCredentials.UserName.UserName = "login"
  svc.ClientCredentials.UserName.Password = "pw"

  ...
End Using

相反的登录名和密码应该是配置的一部分。

Rather the login and password should be part of the configuration.

推荐答案

据我所知,这是不可能的使用serviceModel配置部分由于安全漏洞它会创建。
但是你可以对这些值创建常规的appSettings,并在代码中使用它们:

As far as I know, that is not possible using the serviceModel configuration section due to the security hole it would create. But you could create regular appSettings for these values and use them in code:

svc.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings("...")

我会建议对这种做法虽然,除非你加密配置文件

I would advise against this approach though, unless you encrypt the configuration file.

这篇关于WCF设置在ClientCredentials的App.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆