码迷,mamicode.com
首页 > 其他好文 > 详细

WCF Proxy Authentication Required(407)

时间:2015-12-08 18:28:13      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

WCF Proxy Authentication Required(407)

The Problem

When I’m in the office, I have to use an authenticated proxy to get outside our intranet and to the internet. When I called a service that resides on the web, I got the 407 error. How can we fix this without having to provide an account to our application

The Solution

The answer is actually pretty simple. The answer has nothing to do with WCF, but everything to do with System.Net.

System.Net’s default web proxy does not have the UseDefaultCredentials flag switched on by default. It’s false. Creating a new WebProxy object with the flag set to true is problematical… it turns out to be quite hard to find out the address and port of the default web proxy at runtime, because this is essentially a dynamic thing, and not (as previously thought in the .NET 1.x era) a static thing.

So by far the best thing to do is use your app’s App.Config file to tell System.Net to use the default credentials for authentication to an HTTP proxy server. Something like this:

<system.net>
    <defaultProxy useDefaultCredentials="true">
      <proxy autoDetect="True"/>
    </defaultProxy>
  </system.net>

WCF Proxy Authentication Required(407)

标签:

原文地址:http://www.cnblogs.com/mc67/p/5029786.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!