WebProxy.GetDefaultProxy Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Caution
This method has been deprecated. Please use the proxy selected for you by default. https://go.microsoft.com/fwlink/?linkid=14202
Caution
WebProxy.GetDefaultProxy has been deprecated. Use the proxy selected for you by default.
Caution
This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202
Reads the Internet Explorer nondynamic proxy settings.
public:
static System::Net::WebProxy ^ GetDefaultProxy();
[System.Obsolete("This method has been deprecated. Please use the proxy selected for you by default. https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.WebProxy GetDefaultProxy ();
[System.Obsolete("WebProxy.GetDefaultProxy has been deprecated. Use the proxy selected for you by default.")]
public static System.Net.WebProxy GetDefaultProxy ();
[System.Obsolete("This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.WebProxy GetDefaultProxy ();
public static System.Net.WebProxy GetDefaultProxy ();
[<System.Obsolete("This method has been deprecated. Please use the proxy selected for you by default. https://go.microsoft.com/fwlink/?linkid=14202")>]
static member GetDefaultProxy : unit -> System.Net.WebProxy
[<System.Obsolete("WebProxy.GetDefaultProxy has been deprecated. Use the proxy selected for you by default.")>]
static member GetDefaultProxy : unit -> System.Net.WebProxy
[<System.Obsolete("This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202")>]
static member GetDefaultProxy : unit -> System.Net.WebProxy
static member GetDefaultProxy : unit -> System.Net.WebProxy
Public Shared Function GetDefaultProxy () As WebProxy
Returns
A WebProxy instance that contains the nondynamic proxy settings from Internet Explorer 5.5 and later.
- Attributes
Exceptions
On .NET Core.
Examples
The following code example demonstrates calling this method.
void CheckDefaultProxyForRequest( Uri^ resource )
{
WebProxy^ proxy = (WebProxy^)( WebProxy::GetDefaultProxy() );
// See what proxy is used for resource.
Uri^ resourceProxy = proxy->GetProxy( resource );
// Test to see whether a proxy was selected.
if ( resourceProxy == resource )
{
Console::WriteLine( "No proxy for {0}", resource );
}
else
{
Console::WriteLine( "Proxy for {0} is {1}", resource,
resourceProxy );
}
}
public static void CheckDefaultProxyForRequest(Uri resource)
{
WebProxy proxy = (WebProxy) WebProxy.GetDefaultProxy();
// See what proxy is used for resource.
Uri resourceProxy = proxy.GetProxy(resource);
// Test to see whether a proxy was selected.
if (resourceProxy == resource)
{
Console.WriteLine("No proxy for {0}", resource);
}
else
{
Console.WriteLine("Proxy for {0} is {1}", resource.ToString(),
resourceProxy.ToString());
}
}
Remarks
The GetDefaultProxy method reads the nondynamic proxy settings stored by Internet Explorer 5.5 and later, and creates a WebProxy instance with those settings.
The GetDefaultProxy method does not pick up any dynamic settings that are generated from scripts run by Internet Explorer, from automatic configuration entries, or from DHCP or DNS lookups.
Applications should use the HttpClient.DefaultProxy property instead of the GetDefaultProxy method.
Note
This property is not supported on .NET Core.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기