How to: Specify a Port for the ASP.NET Development Server

When you use the Visual Studio Development Server to run a file-system Web site or a Web application project, by default, the Visual Studio Development Server is invoked on a randomly selected port for localhost. For example, if you are testing a page called MyPage.aspx, when you run the page on the Visual Studio Development Server, the URL of the page might be the following:

https://localhost:31544/MyPage.aspx

If you want to run the Visual Studio Development Server on a specific port, you can configure the server to do so.

Note

Visual Studio cannot guarantee that the port you specify will be available when you run your file-system Web site. If the port is in use when you run a page, Visual Studio displays an error message.

To specify a port for the Visual Studio Development Server in a Web Site Project

  1. In Solution Explorer, click the name of the site.

  2. In the Properties pane, click the down-arrow beside Use dynamic ports and select False from the drop-down list.

    This will enable editing of the Port number property.

  3. In the Properties pane, click the text box beside Port number and type in a port number.

  4. Click outside of the Properties pane. This saves the property settings.

To specify a port for the Visual Studio Development Server in a Web Application Project

  1. In Solution Explorer, click the name of the site.

  2. In the Project menu, click Properties.

  3. Click the Web tab.

  4. Click Specific port and enter a port number.

See Also

Concepts

Types of Web Site Projects in Visual Studio

Other Resources

Web Servers in Visual Studio for ASP.NET Web Projects

Web Application Projects versus Web Site Projects in Visual Studio