HTTP status 407: Proxy Authentication Required

By pass Proxy when invoking a web service

<configuration>
<
system.net>
<
defaultProxy useDefaultCredentials=true enabled = “False”> Set enabled as False to bypass proxy
<proxy usesystemdefault= False proxyaddress=http://a.com bypassonlocal=True />
</defaultProxy>
</
system.net>
</configuration>

To specify proxy credentials in your code

NetworkCredential credential = new NetworkCredential(“user”, “password”,“domain”);

Service1 _service = new Service1();

_service.PreAuthenticate = true;

_service.Credentials = credential;

_service.Proxy = WebProxy.GetDefaultProxy();

_service.Proxy.Credentials = CredentialCache.DefaultCredentials;

[more details]

Advertisements
Posted in C#. 4 Comments »

4 Responses to “HTTP status 407: Proxy Authentication Required”

  1. mohammedatef83 Says:

    very simple and useful,thanks

  2. http status 407 proxy authentication required « Mohammed Atef’s Technical blog Says:

    […] this exception http 407 proxy authentication required? now you can solve this issue if you click here. just add the configuration in the post into your app.config or web.config I would like to thank […]

  3. juvyc Says:

    Hi,

    Seems messy, where I can take a look at the app.config or web.config my server? then where to put these codes

    Set enabled as False to bypass proxy

    And the second reference codes, where should I put it to make it working.

    NetworkCredential credential = new NetworkCredential(“user”, “password”,“domain”);

    Service1 _service = new Service1();

    _service.PreAuthenticate = true;

    _service.Credentials = credential;

    _service.Proxy = WebProxy.GetDefaultProxy();

    _service.Proxy.Credentials = CredentialCache.DefaultCredentials;

    Best regards,
    juvyc

    • Usman Shaheen Says:

      web.config is located in root folder of your web application, usually where you have default.aspx.
      the code should appear just before where you invoke service method.
      if case of any confusion, please share your mail address and we will discuss


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: