How to assign ClientCredentials to WCF Client while binding with Ninject Kernel in Test_at_server configuration? -


i using ninject inject wcf client in local environment , working fine. how have implemented it:

private static ikernel createkernel()     {         var kernel = new standardkernel();          kernel.bind<func<ikernel>>().tomethod(ctx => () => new bootstrapper().kernel);          kernel.bind<ihttpmodule>().to<httpapplicationinitializationhttpmodule>();          registerservices(kernel);         return kernel;     } 

and in registerservices(kernel) method have follwing implementation:

private static void registerservices(ikernel kernel)     {     #if debug         kernel.bind<mywcfclient.imywcf>().to<mywcfclient.mywcfclient>();      #elif test_at_server                     kernel.bind<mywcfclient.imywcf>().to<mywcfclient.mywcfclient>()               /*.withconstructorargument("username", credentials.username.username = "user")               .withconstructorargument("password", credentials.username.password = "password")*/;     #endif     } 

what trying is, when deploying web application in server, ninject should inject wcf credentials because wcf @ server needs authenticated.

i have tried , works me!

#if debug     kernel.bind<mywcfclient.imywcf>().to<mywcfclient.mywcfclient>();     #elif test_at_server     clientcredentials credentials = new clientcredentials();     kernel.bind<mywcfclient.imywcf>().to<mywcfclient.mywcfclient>()         .withconstructorargument("username", credentials.username.username = "username")        .withconstructorargument("password", credentials.username.password = "password"); #else #endif 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -