简体   繁体   中英

Set localhost port fixed/static for project debugging in vs2015

l am using Asp.Net Maker 2016 for generating my project. So, l browse my project via vs2015. The problem is after I generate my project from Asp.Net Maker tool and open it in vs2015, the URL of my project is changed.

something like :

http://localhost:51624/ADD

I want to set the port fixed not dynamic so, how I can do this in vs2015 or Asp.Net 2016 Maker tool?

Visual Studio uses IIS Express to run Web Projects . When a project is run first time IISExpress creates an entry to applicationhost.config file for the project and assigns a random port to it. The file is located at - %userprofile%\\Documents\\IISExpress\\config folder.

Project entries in the file looks like this -

<site name="ProjectName" id="5">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="d:\physical path" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:59302:localhost" />
    </bindings>
</site>

Notice the bindingInformation="*:59302:localhost" in the above section. Here the port number is 59302 . You can change this port number to anything you like and next time Visual Studio runs the project it will use your assigned port number.

Its best to close all instances of VS and also confirm that IISExpress is not running before changing the file. Also, keep a backup of the file beforehand just in case.

The port you assign also needs to be free. ie no other application should be using the port. Else Visual Studio will fail to run the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM