running ASP.net application on a different port

Anjali Agarwal 1,531 Reputation points
2021-11-10T04:15:49.257+00:00

I need to run my asp.net application on port 5000 because this port number is configured in my azure portal. In order to put the Port number 5000, I changed the web tab in the project properties to run at 5000 like this:

Goqv4.png

I also clicked on "Create Virtual directory" after putting the new port number.

After this, I changed the applicationhost.config file that exists in my solution folder and changed the bindings like this.I unloaded the project and changed the bindings and then loaded the project again.

 <bindings>
                        <binding protocol="http" bindingInformation="*:5000:localhost" />
                        <binding protocol="https" bindingInformation="*:5000:localhost" />
   </bindings>

The problem is no matter how many times, I change the binding information for https, it always changes back to 44347. How can I keep the port to 5000 for https? I am using Visual studio 2019. .net framework 4.7.2.

any help will be greatly appreciated.

Windows development Internet Information Services
Developer technologies ASP.NET Other
Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. Bruce Zhang-MSFT 3,771 Reputation points
    2021-11-11T02:55:10.573+00:00

    Hi @Anjali Agarwal ,

    One thing you need to know is that https use 443 as default port. So only 443xxx ports can be used by https. When I change the port to 5000, it cannot work. But when I change 44319 to 44350, it can work well. HTTP and HTTPS cannot use same port. You cannot set both of them use 5000.

    Another thing is change port in visual studio is not not really change. Each time you change the port, IIS express creates a new site with new url. The new url still points to the physical folder of application.
    148441-1.jpg
    VS may have some problems and cannot use the updated port when debugging. You can directly change the port in the browser.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.