UriBuilder.Port Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the port number of the URI.

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

public int Port { get; set; }

Property Value

Type: System.Int32

The port number of the URI.

Exception Condition
ArgumentOutOfRangeException

The port cannot be set to a value less than -1 or greater than 65,535.

The port number defines the protocol port for contacting the host referenced in the URI. If a port is not specified as part of the URI, the Port property returns the value of -1 to indicate that the default port value for the protocol scheme will be used to connect to the host. If the Port property is set to a value of -1, this indicates that the default port value for the protocol scheme will be used to connect to the host.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: