HttpWebRequest.ServicePoint Özellik

Tanım

İstek için kullanılacak hizmet noktasını alır.

C#
public System.Net.ServicePoint ServicePoint { get; }

Özellik Değeri

İnternet kaynağına ağ bağlantısını temsil eden bir ServicePoint.

Örnekler

C#
private static void makeWebRequest(int hashCode, string Uri)
{
    HttpWebResponse res = null;

    // Make sure that the idle time has elapsed, so that a new
    // ServicePoint instance is created.
    Console.WriteLine("Sleeping for 2 sec.");
    Thread.Sleep(2000);
    try
    {
        // Create a request to the passed URI.
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Uri);

        Console.WriteLine("\nConnecting to " + Uri + " ............");

        // Get the response object.
        res = (HttpWebResponse)req.GetResponse();
        Console.WriteLine("Connected.\n");

        ServicePoint currentServicePoint = req.ServicePoint;

        // Display new service point properties.
        int currentHashCode = currentServicePoint.GetHashCode();

        Console.WriteLine("New service point hashcode: " + currentHashCode);
        Console.WriteLine("New service point max idle time: " + currentServicePoint.MaxIdleTime);
        Console.WriteLine("New service point is idle since " + currentServicePoint.IdleSince );

        // Check that a new ServicePoint instance has been created.
        if (hashCode == currentHashCode)
            Console.WriteLine("Service point reused.");
        else
            Console.WriteLine("A new service point created.") ;
    }
    catch (Exception e)
    {
        Console.WriteLine("Source : " + e.Source);
        Console.WriteLine("Message : " + e.Message);
    }
    finally
    {
        if (res != null)
            res.Close();
    }
}

Açıklamalar

Dikkat

WebRequest, HttpWebRequest, ServicePointve WebClient kullanım dışıdır ve bunları yeni geliştirme için kullanmamalısınız. Bunun yerine HttpClient kullanın.

İstek yeniden yönlendirilirse ServicePoint.Address özelliği HttpWebRequest.Address farklı olabilir.

Şunlara uygulanır

Ürün Sürümler
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.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