How can I change IIS Express port for a site

后端 未结 12 1402
死守一世寂寞
死守一世寂寞 2020-11-29 02:32

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

相关标签:
12条回答
  • 2020-11-29 03:12

    If you just want to change the port because it is already in use. Follow the following steps.

    In Visual studio

    1. Right-click on Project Node and Unload Project
    2. Right-click on Project Node and Edit .csproj file.
    3. Search for the following tags and remove them
    <DevelopmentServerPort>62140</DevelopmentServerPort>
    <DevelopmentServerVPath></DevelopmentServerVPath>
    <IISUrl>http://localhost:62116/</IISUrl>
    
    1. press Ctrl + S to save the document
    2. Right-click on Project Node and load Project

    It will work by selecting another port randomly.

    For further information. please click

    0 讨论(0)
  • 2020-11-29 03:13

    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.

    0 讨论(0)
  • 2020-11-29 03:13

    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.

    0 讨论(0)
  • 2020-11-29 03:18

    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.

    0 讨论(0)
  • 2020-11-29 03:20

    .Net Core

    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.

    0 讨论(0)
  • 2020-11-29 03:21

    You can first start IIS express from command line and give it a port with /port:port-number see other options.

    0 讨论(0)
提交回复
热议问题