c# - WCF. Set user credentials -


sorry, english bad.

i have wcf services project , asp.net mvc project i'm using ninject wcf client extension inject services in example

 bind<iservice>().toservicechannel(); 

now i'm need add authentication , authorization wcf services. have implemented usernamepasswordvalidator , iauthorizationpolicy.

in examples used service reference , user credentials added here:

serviceclient host = new serviceclient(); host.clientcredentials.username.username = "user"; host.clientcredentials.username.password = "pass"; 

but didn't create service reference. have interfaces. , use here:

public class homecontroller : controller {     private readonly iservice _service;     public homecontroller(iservice service)     {         _service = service;         } } 

how can add user credentials?

you need create channelfactory set user credentials:

example :

var result = new channelfactory<iservice>("*", new endpointaddress(serviceaddress));     result.credentials.username.username = "username";     result.credentials.username.password = "password"; 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -