Leer en inglés

Compartir a través de


ServicePointManager.FindServicePoint Método

Definición

Busca un objeto ServicePoint existente o crea un objeto ServicePoint nuevo para administrar las comunicaciones de esta solicitud.

Sobrecargas

FindServicePoint(Uri, IWebProxy)
Obsoletos.

Busca un objeto ServicePoint existente o crea un objeto ServicePoint nuevo para administrar las comunicaciones con el objeto Uri especificado.

FindServicePoint(Uri)
Obsoletos.

Busca un objeto ServicePoint existente o crea un objeto ServicePoint nuevo para administrar las comunicaciones con el objeto Uri especificado.

FindServicePoint(String, IWebProxy)
Obsoletos.

Busca un objeto ServicePoint existente o crea un objeto ServicePoint nuevo para administrar las comunicaciones con el identificador URI especificado.

FindServicePoint(Uri, IWebProxy)

Source:
ServicePointManager.cs
Source:
ServicePointManager.cs
Source:
ServicePointManager.cs

Precaución

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Busca un objeto ServicePoint existente o crea un objeto ServicePoint nuevo para administrar las comunicaciones con el objeto Uri especificado.

C#
public static System.Net.ServicePoint FindServicePoint(Uri address, System.Net.IWebProxy? proxy);
C#
[System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.ServicePoint FindServicePoint(Uri address, System.Net.IWebProxy? proxy);
C#
public static System.Net.ServicePoint FindServicePoint(Uri address, System.Net.IWebProxy proxy);

Parámetros

address
Uri

Un objeto Uri que contiene la dirección del recurso de Internet con el que se establecerá el contacto.

proxy
IWebProxy

Los datos del proxy para esta solicitud.

Devoluciones

El objeto ServicePoint que administra las comunicaciones para la solicitud.

Atributos

Excepciones

address es null.

Se ha alcanzado el número máximo de objetos ServicePoint definido en MaxServicePoints.

Comentarios

El FindServicePoint método devuelve el ServicePoint objeto asociado al nombre de host de Internet especificado. Si no existe ningún ServicePoint objeto para ese host, el ServicePointManager objeto crea uno.

Consulte también

Se aplica a

.NET 9 y otras versiones
Producto Versiones (Obsoleto)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 9 (6, 7, 8)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

FindServicePoint(Uri)

Source:
ServicePointManager.cs
Source:
ServicePointManager.cs
Source:
ServicePointManager.cs

Precaución

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Busca un objeto ServicePoint existente o crea un objeto ServicePoint nuevo para administrar las comunicaciones con el objeto Uri especificado.

C#
public static System.Net.ServicePoint FindServicePoint(Uri address);
C#
[System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.ServicePoint FindServicePoint(Uri address);

Parámetros

address
Uri

El objeto Uri del recurso de Internet con el que se establecerá contacto.

Devoluciones

El objeto ServicePoint que administra las comunicaciones para la solicitud.

Atributos

Excepciones

address es null.

Se ha alcanzado el número máximo de objetos ServicePoint definido en MaxServicePoints.

Comentarios

El FindServicePoint método devuelve el ServicePoint objeto asociado al nombre de host de Internet especificado. Si no existe ningún ServicePoint objeto para ese host, el ServicePointManager objeto crea uno.

Consulte también

Se aplica a

.NET 9 y otras versiones
Producto Versiones (Obsoleto)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 9 (6, 7, 8)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

FindServicePoint(String, IWebProxy)

Source:
ServicePointManager.cs
Source:
ServicePointManager.cs
Source:
ServicePointManager.cs

Precaución

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Busca un objeto ServicePoint existente o crea un objeto ServicePoint nuevo para administrar las comunicaciones con el identificador URI especificado.

C#
public static System.Net.ServicePoint FindServicePoint(string uriString, System.Net.IWebProxy? proxy);
C#
[System.Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId="SYSLIB0014", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Net.ServicePoint FindServicePoint(string uriString, System.Net.IWebProxy? proxy);
C#
public static System.Net.ServicePoint FindServicePoint(string uriString, System.Net.IWebProxy proxy);

Parámetros

uriString
String

Identificador URI del recurso de Internet con el que se establecerá contacto.

proxy
IWebProxy

Los datos del proxy para esta solicitud.

Devoluciones

El objeto ServicePoint que administra las comunicaciones para la solicitud.

Atributos

Excepciones

El identificador URI especificado en uriString no es válido.

Se ha alcanzado el número máximo de objetos ServicePoint definido en MaxServicePoints.

Ejemplos

En el ejemplo de código siguiente se muestra cómo llamar a este método para tener acceso a un ServicePoint objeto .

C#
public static void Main(string[] args)
{
    int port = 80;

    // Define a regular expression to parse the user's input.
    // This is a security check. It allows only
    // alphanumeric input strings between 2 to 40 characters long.
    Regex rex = new Regex(@"^[a-zA-Z]\w{1,39}$");

    if (args.Length < 1)
    {
        showUsage();
        return;
    }
    string proxy = args[0];

    if (!(rex.Match(proxy)).Success)
    {
        Console.WriteLine("Input string format not allowed.");
        return;
    }
    string proxyAdd = "http://" + proxy + ":" + port;

    // Create a proxy object.
    WebProxy DefaultProxy = new WebProxy(proxyAdd, true);

    // Set the proxy that all HttpWebRequest instances use.
    WebRequest.DefaultWebProxy = DefaultProxy;

    // Get the base interface for proxy access for the
    // WebRequest-based classes.
    IWebProxy Iproxy = WebRequest.DefaultWebProxy;

    // Set the maximum number of ServicePoint instances to
    // maintain. If a ServicePoint instance for that host already
    // exists when your application requests a connection to
    // an Internet resource, the ServicePointManager object
    // returns this existing ServicePoint instance. If none exists
    // for that host, it creates a new ServicePoint instance.
    ServicePointManager.MaxServicePoints = 4;

    // Set the maximum idle time of a ServicePoint instance to 10 seconds.
    // After the idle time expires, the ServicePoint object is eligible for
    // garbage collection and cannot be used by the ServicePointManager object.
    ServicePointManager.MaxServicePointIdleTime = 10000;

    ServicePointManager.UseNagleAlgorithm = true;
    ServicePointManager.Expect100Continue = true;
    ServicePointManager.CheckCertificateRevocationList = true;
    ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit;
    // Create the Uri object for the resource you want to access.
    Uri MS = new Uri("http://msdn.microsoft.com/");

    // Use the FindServicePoint method to find an existing
    // ServicePoint object or to create a new one.
    ServicePoint servicePoint = ServicePointManager.FindServicePoint(MS, Iproxy);

    ShowProperties(servicePoint);

    int hashCode = servicePoint.GetHashCode();

    Console.WriteLine("Service point hashcode: " + hashCode);

    // Make a request with the same scheme identifier and host fragment
    // used to create the previous ServicePoint object.
    makeWebRequest(hashCode, "http://msdn.microsoft.com/library/");
}

Comentarios

El FindServicePoint método devuelve el ServicePoint objeto asociado al nombre de host de Internet especificado. Si no existe ningún ServicePoint objeto para ese host, el ServicePointManager objeto crea uno.

Consulte también

Se aplica a

.NET 9 y otras versiones
Producto Versiones (Obsoleto)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 9 (6, 7, 8)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1