Cannot start the website because administrative privileges are required to bind to the hostname or port

This error was thrown when I ran the newly downloaded BlogEngine.NET code from Visual Studio 2015.
First thing first, this has got nothing to do with ‘Run as administrator‘ option. The error states that there is a permission issue on the port on which IISExpress was attempting to run the site. I hadn’t changed anything to the original code base. So it was apparent that the port setting must have got imported. My understanding was that Visual Studio auto manages this setting, i.e., if the attempted port is busy, then VS automatically finds the next available slot. As it turned out, this is not the case.

 
Anyways, the solution is to remove the old references of the url (IISUrl) and the port (DevelopmentServerPort) from the csproj file. Apparantly, if you don’t provide any specific url & port, Visual Studio will automatically look for an available port. Yes! automatic.

Following are the steps to accomplish the same:

  • First, ensure that, ‘Apply server settings to all users (store in project file)‘ is checked.
  • From the Solution Explorer in Visual Studio, right click the web project and select ‘Unload Project‘.
  • Next on the same project, right click and select ‘Edit‘.
  • Find the xml tags and and remove them.
  • Reload the project and run.
As you can see in the address bar, the site’s running and is doing so on a different port.
Advertisements