Visual Studio 2010 (Pre SP1): How to change the ASP.NET Port Number


Another glitch that is mildly frustrating with Visual Studio 2010 is trying to change the port number on the ASP.NET development environment. If you’re like me, you’re developing on multiple machines and you probably have a local URL specified in your web.config file. As the port number by default is dynamic for the project, it means that whereas it will be the same between builds on that machine, it won’t be the same on different machines (and then you end up having to edit the web.config every time you switch machines, in my case from my desktop to the laptop). The easy solution is to just tell the project to use a static port number that’s the same between machines.

On the properties dialog for the web site, there is a property called “Use dynamic ports” and it’s set to “True” by default (the port number will be grayed out). You will want to toggle that to “False”. Now, here’s the gotcha. After you toggle the “Use dynamic ports” property, the “Port number” property will still be grayed out instead of you being able to edit it. Even if you close the properties dialog and re-open it, it will still be grayed out. Even if shut down the local web server, it will stay grayed out. Here’s the work around:

  1. Toggled the Use dynamic ports property to True for your site.
  2. Save your solution.
  3. Close Visual Studio 2010
  4. Reopen Visual Studio 2010 and open your web-site.

Upon opening your web-site you’ll now find that as below, the Port number is now able to be changed. Now a caveat. It is possible that Visual Studio is running slow enough that even after 5-10 seconds the property doesn’t update itself to be editable. I have also seen where the property will update, but it has a considerable lag like it’s waiting for background events to process first. This is also unacceptable in my opinion. I have read the performance arguments about VS2010 (about being loaded ready to go instead of fast starting) and simply don’t see that in practice. There are a few items that are considerably faster (like the Add References dialog) but by in large in what I do on a day to day basis I end up waiting on the IDE far more than I used to and I spend more time looking through Intellisense lists because don’t return the results I expect.

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.