WebProxy.GetDefaultProxy Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Attention
This method has been deprecated. Please use the proxy selected for you by default. https://go.microsoft.com/fwlink/?linkid=14202
Attention
WebProxy.GetDefaultProxy has been deprecated. Use the proxy selected for you by default.
Attention
This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202
Lit les paramètres de proxy non dynamiques des options Internet.
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
Retours
Instance WebProxy qui contient les paramètres de proxy non dynamiques des options Internet.
- Attributs
Exceptions
Sur .NET Core.
Exemples
L’exemple de code suivant illustre l’appel de cette méthode.
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());
}
}
Remarques
La GetDefaultProxy méthode lit les paramètres de proxy non dynamiques à partir des options Internet de l’ordinateur et crée une WebProxy instance avec ces paramètres.
La GetDefaultProxy méthode ne récupère pas de paramètres dynamiques générés à partir de scripts exécutés par Internet Explorer, d’entrées de configuration automatiques ou de recherches DHCP ou DNS.
Les applications doivent utiliser la HttpClient.DefaultProxy propriété au lieu de la GetDefaultProxy méthode .
Notes
Cette propriété n’est pas prise en charge sur .NET Core.