Reputation: 3381
I have a legacy ASP.NET WebForms app I need to get running. When running it in Visual Studio 2022 it uses port 50007 (http://localhost:50007/). That port has been helpfully reserved by Hyper-V and so I get an error (failed to register URL.... 0x80070020) which is basically: access denied to the port.
How do I change the development/debugging port? Googling provides lots of information, mostly about MVC which does not apply here. I have tried deleting the project's .vs folder and the IISExpress folder (in Documents). There is no mention of 50007 in the project folder.
The 50007 persists and I can't run my code.
I could uninstall Hyper-V but that would probably cause carnage elsewhere.
Any suggestions?
Upvotes: 0
Views: 10525
Reputation: 31
If you see it in the application config and launchsettings.json
files:
C:\MY PROJECT LOCATION\config\applicationhost.config (1 hit)
Line 162: <binding protocol="https" bindingInformation="*:44310:localhost" />
Upvotes: 0
Reputation: 1
I needed to change SSL port and updating '.vs..\config\applicationhost.config' and 'MyProject.csproj' did not help - after I reload MyProject in VS I will always see old port number.
I fixed it by manually updating 'MyProject.csproj.user' file as well!
Upvotes: 0
Reputation: 21
For web site application set the new port number in the file .vs\..\config\applicationhost.config
too. If the same number is used by template WebSite1
(usually 8080), change template port to different number.
Upvotes: 1
Reputation: 49039
Well assuming say a web forms project?
When you create a project, I think vs just makes up a port.
But, from vs go
Project->"project name" properties.
Then on the web tab, you should see this:
So, just enter a new/different port number in above, and hit "Create Virtual directory". Now, say f5 to run/debug, it should use this new port.
Now, the above assumes we are using a asp.net web site "project".
That means the above menu is from this option:
However, it is possible that you using a asp.net website, and not a web site project (I don't use nor like that option).
Hence, you "might" then be opening this as a "web site".
Assuming you using a web site, then you would be using file->open web site (as opposed to file->open project).
If that is the case, then of course you don't have a project/properties page.
That being the 2nd possible case?
Then you have to edit the .sln manually.
So, open the folder location (you can right click on the project and choose "Open Folder in File exploer"
I would after above, close the project - actually CLOSE vs also.
Ok, now open the .sln file with note pad, and you want to change this line:
I don't think it is required to change the other path names, but give this 2nd approach a try.
Upvotes: 3