Share via


Port Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets the port number of this URI.

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

Syntax

'Declaration
Public ReadOnly Property Port As Integer
public int Port { get; }
public:
property int Port {
    int get ();
}
member Port : int with get
function get Port () : int

Property Value

Type: System. . :: . .Int32
An Int32 value that contains the port number for this URI.

Exceptions

Exception Condition
InvalidOperationException

This instance represents a relative URI, and this property is valid only for absolute URIs.

Remarks

The port number defines the protocol port used for contacting the server referenced in the URI. If a port is not specified as part of the URI, the Port property returns the default value for the protocol. If there is no default port number, this property returns -1.

.NET Framework Security

See Also

Reference

Uri Class

System Namespace