Share via


SPSite.Port Property

Gets the port number that is used for input and output on the virtual server that contains the site collection.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public ReadOnly Property Port As Integer
    Get
'Usage
Dim instance As SPSite
Dim value As Integer

value = instance.Port
public int Port { get; }

Property Value

Type: System.Int32
A 32-bit integer that indicates the port number.

Examples

The following code example displays the port number for the specified site collection in a console application.

Using oSiteCollection As New SPSite("http://" + System.Environment.MachineName)
    Console.WriteLine(("port: " + oSiteCollection.Port.ToString()))
End Using
using (SPSite oSiteCollection = new SPSite("http://" + 
   System.Environment.MachineName))
{
    Console.WriteLine("port: " + oSiteCollection.Port.ToString());
}

Note

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

See Also

Reference

SPSite Class

SPSite Members

Microsoft.SharePoint Namespace