Export (0) Print
Expand All

HttpWebRequest.ServicePoint Property

Gets the service point to use for the request.

Namespace:  System.Net
Assembly:  System (in System.dll)

public function get ServicePoint () : ServicePoint

Property Value

Type: System.Net.ServicePoint
A ServicePoint that represents the network connection to the Internet resource.

The ServicePoint.Address property may be different from HttpWebRequest.Address if the request is redirected.

Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note: This property is a null reference (Nothing in Visual Basic) until the request is sent because of the additional network transmission required.

No code example is currently available or this language may not be supported.
void makeWebRequest(int hashCode, String* Uri)
{
    HttpWebResponse* res = 0;

    // Make sure that the idle time has elapsed, so that a new 
    // ServicePoint instance is created.
    Console::WriteLine(S"Sleeping for 2 sec.");
    Thread::Sleep(2000);

    try
    {
        // Create a request to the passed URI.
        HttpWebRequest* req = dynamic_cast<HttpWebRequest*> (WebRequest::Create(Uri));
        Console::WriteLine(S"\nConnecting to {0} ............", Uri);

        // Get the response object.
        res = dynamic_cast<HttpWebResponse*>(req->GetResponse());
        Console::WriteLine(S"Connected.\n");
        ServicePoint* currentServicePoint = req->ServicePoint;

        // Display new service point properties.
        int currentHashCode = currentServicePoint->GetHashCode();
        Console::WriteLine(S"New service point hashcode: {0}", __box(currentHashCode));
        Console::WriteLine(S"New service point max idle time: {0}", __box(currentServicePoint->MaxIdleTime));
        Console::WriteLine(S"New service point is idle since {0}", __box(currentServicePoint->IdleSince));

        // Check that a new ServicePoint instance has been created.
        if (hashCode == currentHashCode)
            Console::WriteLine(S"Service point reused.");
        else
            Console::WriteLine(S"A new service point created.");
    }
    catch(Exception* e)
    {
        Console::WriteLine(S"Source : {0}", e->Source);
        Console::WriteLine(S"Message : {0}", e->Message);
    }
    __finally
    {
        if (res != 0)
            res->Close();
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft