Take the 2-minute tour ×

I have a few questions about localhost and port numbers as this is an area where I do not have a lot of knowledge, and because I recently had to work with setting up Visual Studio projects and IIS and there are things I'm not clear on.

I have the following questions on the things I find confusing. I thought it made more sense to include them all in one question instead of making separate questions.

  1. I have noticed a random port number is generated with projects I have worked on in the past, but I recently saw a project where the port number was fixed. What is the purpose of having a fixed/default localhost port number? i.e is it particularly useful on projects that have many programmers working on the project?

  2. If a solution contains multiple projects (for example, WCF services, Domain, MVC/Web pages), is it possible to setup a different localhost port for each of them? If so, what is the benefit of this?

  3. If a solution contains multiple projects and has different localhost urls/port numbers, must there be a corresponding website (and application pool) for each project in IIS? Or just for the project that contains the actual web pages?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted
  1. The usual pattern is IIS generates a random port number but once generated said port number is fixed. The main advantage is when you've got parts of a project that communicate. For example, if you are building a WPF front-end to a web service you'd need to know where the web service is. And it is very convenient for it to live in a fixed place development-wise, especially when other developers enter the fray.

  2. The default behavior is a different port per project. In fact, depending on local setups, making them all use the same port can be difficult if not impossible.

  3. Not necessarily. Visual Studio 2008 and 2010 ship with something called Cassini, a self-hosted development web server. This is the default server which spins up. In 2010 Microsoft released IIS Express which is a much better option -- it is a full blown local version of IIS which means it behaves almost exactly like your production environment. IIS express does have app pools, but they are all running in the context of the logged in user not as APPLICATION POOL IDENTITY. Developers generally need not worry about managing their app pools.

share|improve this answer
Thanks for your answer, the detail is appreciated. If a project has multiple projects and localhost port numbers, and IIS setup is removed - is there a way to store what the settings are for a given visual studio solution? i.e something that can be executed and setup IIS for each of the projects? –  Theomax Sep 3 '12 at 17:08
The port numbers live in each of the .csproj files -- it will generate them when it needs them if it can't find them. –  Wyatt Barnett Sep 3 '12 at 17:18
add comment

Your Answer


