Set WCF ClientCredentials in App.config

后端 未结 4 1940
逝去的感伤
逝去的感伤 2020-12-30 08:40

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

I would like to avoid doing this:

Using svc As New MyServiceClient
  svc.ClientCre         


        
4条回答
  •  臣服心动
    2020-12-30 09:11

    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.

提交回复
热议问题