I want to change the port number on which my website runs while debugging from Visual Studio. I am using Visual Studio 2012, and I am using ASP.NET MVC 4 for my projects I w
If you just want to change the port because it is already in use. Follow the following steps.
In Visual studio
<DevelopmentServerPort>62140</DevelopmentServerPort> <DevelopmentServerVPath></DevelopmentServerVPath> <IISUrl>http://localhost:62116/</IISUrl>
It will work by selecting another port randomly.
For further information. please click
If we are talking about a WebSite, not web app, my issue was that the actual .sln folder was somewhere else than the website, and I had not noticed. Look for the .sln path and then for the .vs (hidden) folder there.
I'm using VS 2019.
if your solution has more than one project / class libraries etc, then you may not see the Web tab when clicking on Solution explorer properties.
Clicking on the MVC project and then checking properties will reveal the web tab where you can change the port.
I'd the same issue on a WCF project on VS2017. When I debug, it gives errors like not able to get meta data, but it turns out the port was used by other process. I got some idea from here, and finally figure out where the port was kept. There are 2 places: 1. C:...to your solution folder....vs\config\applicationhost.config. Inside, you can find the site that you debug. Under , remove the that has port issue. 2. C:...to your project folder...\, you will see a file with ProjectName.csproj.user. Remove this file.
So, close the solution, remove the and the user file mentioned above, then reopen the solution, VS will find another suitable port for the site.
For those who got here looking for this configuration in .Net core this resides in the lauchSettings.json
. Just edit the port in the property "applicationUrl"
.
The file should look something like this:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53950/", //Here
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "index.html",
"environmentVariables": {
"Hosting:Environment": "Development"
},
}
}
}
Or you can use the GUI by double clicking in the "Properties" of your project.
Note: I had to reopen VS to make it work.
You can first start IIS express from command line and give it a port with /port:port-number see other options.