searchforsolutions

Just another WordPress.com site

How to supply dedicated credentials for webproxy authentication in WCF client – Part 2


In my previous blog about the same topic we talked about webproxy authentication in WCF client using configuration file changes.

But the same can be solved programmatically.I’m going to discuss the same here.Its pretty simple & straight forward!

In the code where you initialise you application much before any WCF service calls are made, insert the following piece of code

WebProxy wproxy = new WebProxy(“http://<proxy address>:<proxy port>”, true,null,new NetworkCredential(“<user name>”, “<user password>”,”<domain>”));
WebRequest.DefaultWebProxy = wproxy;

The WCF runtime will acquire proxy setting from WebRequest.DefaultWebProxy property if the <system.net> and WCF <binding> remains useDefaultproxy as “true”.

Then you are done!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: