'How to modify port in .Net framework web api

I write a demo program, to use .NET Framework Web Api2. For some reason, I have to use .NET Framework rather than .Net Core. But I've got a problem, how to modify the port? It's always 57518. I want to change it.



Solution 1:[1]

I believe that you are using IIS Express, right?

In this way you need to execute the following steps:

  1. In the Solution Explorer, right-click on the Project and select Properties. (https://i.stack.imgur.com/2UH2G.png).

  2. Now the property window will be open.

  3. Select the "Web" tab, check the "Override Application Root URL" Radio Button and enter the URL with your specific port (https://i.stack.imgur.com/F4mU6.png).

Now your web api will run in the informed URL.

Solution 2:[2]

In Asp.NetCore WebApi application you can change port for webapi in VisualStudio "launchsettings.json" file.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 leandro.andrioli
Solution 2