Changing project port number in Visual Studio 2013
This has proved to be elusive for me (WebSite Project) until I figured out the following procedure, which combines the solution provided by @Jimmy, with the added step of checking out the solution from Source Control
Steps: (if using VS2013+ with website project and SourceControl)
- Check out the Solution file only (from sourceControl) (this can be tricky. the easiest way to do this is to make a small change in the Solution file properties/settings and then undo if necessary)
- Locate the solution file (e.g. solution.sln) in exploer, and open in text editor.
- Locate the entry:
VWDPort = ......
and change to desired port: (example: "60000" - depends on your IISExpress Settings) - save the change (will prompt to reload solution)
Well, I simply could not find this (for me) mythical "Use dynamic ports" option. I have post screenshots.
On a more constructive note, I believe that the port numbers are to be found in the solution file AND CRUCIALLY cross referenced against the IIS Express config file
C:\Users\<username>\Documents\IISExpress\config\applicationhost.config
I tried editing the port number in just the solution file but strange things happened. I propose (no time yet) that it needs a consistent edit across both the solution file and the config file.
Right click the web application and select "properties"
There should be a 'Web' tab where http://localhost:XXXXX
is specified - change the port number there and this will modify the configuration to use your new port number.
I usually start at 10000 and increment by 1 for each web app, to attempt to steer well clear of other applications and port numbers.
There are two project types in VS for ASP.NET projects:
Web Application Projects (which notably have a .csproj or .vbproj file to store these settings) have a Properties node under the project. On the Web tab, you can configure the Project URL (assuming IIS Express or IIS) to use whatever port you want, and just click the Create Virtual Directory button. These settings are saved to the project file:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<DevelopmentServerPort>10531</DevelopmentServerPort>
...
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
Web Site Projects are different. They don't have a .*proj file to store settings in; instead, the settings are set in the solution file. In VS2013, the settings look something like this:
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebSite1(1)", "http://localhost:10528", "{401397AC-86F6-4661-A71B-67B4F8A3A92F}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.5"
...
SlnRelativePath = "..\..\WebSites\WebSite1\"
DefaultWebSiteLanguage = "Visual Basic"
EndProjectSection
EndProject
Because the project is identified by the URL (including port), there isn't a way in the VS UI to change this. You should be able to modify the solution file though, and it should work.