IWebProxy.IsBypassed(Uri) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Anger att proxyn inte ska användas för den angivna värden.
public:
bool IsBypassed(Uri ^ host);
public bool IsBypassed(Uri host);
abstract member IsBypassed : Uri -> bool
Public Function IsBypassed (host As Uri) As Boolean
Parametrar
Returer
trueom proxyservern inte ska användas för host, annars . false
Exempel
I följande exempel används IsBypassed egenskapen för att avgöra om proxyservern ska användas för den angivna värden.
WebProxy_Interface webProxy_Interface = new WebProxy_Interface(new Uri("http://proxy.example.com"));
webProxy_Interface.Credentials = new NetworkCredential("myusername", "mypassword");
Uri testUri = new Uri("http://www.contoso.com");
// Determine whether the Web proxy can be bypassed for the site "http://www.contoso.com".
if(webProxy_Interface.IsBypassed(testUri))
{
Console.WriteLine("Web Proxy is by passed");
}
else
{
Uri? webProxyServer = webProxy_Interface.GetProxy(testUri);
// In general, we wouldn't expect the condition (`webProxyServer! == testUri`) true here, if IsBypassed returns `false`.
// However, technically our interface can allow that.
if (webProxyServer is null || webProxyServer! == testUri)
{
Console.WriteLine("Web proxy is bypassed");
}
else
{
Console.WriteLine("Web proxy is not bypassed");
Console.WriteLine($"The web proxy is: {webProxyServer!}");
}
}
Public Shared Sub Main()
Dim webProxy_Interface As New WebProxy_Interface(New Uri("http://proxy.example.com"))
webProxy_Interface.Credentials = New NetworkCredential("myusername", "mypassword")
Console.WriteLine("The web proxy is : {0}", webProxy_Interface.GetProxy(New Uri("http://www.contoso.com")))
'Determine whether the Web proxy can be bypassed for the site "http://www.contoso.com".
console.writeline("For the Uri http://www.contoso.com , the ")
If webProxy_Interface.IsBypassed(New Uri("http://www.contoso.com")) Then
Console.WriteLine("webproxy is by passed")
Else
Console.WriteLine("webproxy is not bypassed")
End If
End Sub
Kommentarer
Metoden IsBypassed anger om du vill använda proxyservern för att komma åt värden som anges i parametern host . Om IsBypassed returnerar trueanvänds inte proxyn för att kontakta värden och begäran skickas direkt till servern. Att komma false från IsBypassed garanterar inte att URI:n är proxied. Du måste fortfarande anropa GetProxy metoden för att fastställa detta.