How to set/change port number for a project using IIS Express in Visual Studio

For running projects locally through Visual Studio and IIS Express, your URL will be something like http://localhost:9257/. As a developer, you probably often have many different projects on your machine, and using the same port number on the projects could cause problems. So if this is the case, or if some other service is using your port, this is how you change it.

Here is a fast recipe on how to manually change the port number to whatever number you want:

  1. In Solution Explorer, right-click the name of the web application and select Properties. Click the Web tab.
  2. In the Servers section, under dropdown selection for IIS Express, change the port number in the Project URL box.
  3. To the right of the Project URL box, click Create Virtual Directory, and then click OK.
  4. Save your changes, either by CTRL+S or clicking Save Selected Items that you will find in the File-menu.

After this is done, you can click the green play button and enjoy working locally on a brand new port...