How can I change the IIS Express port for a site

I want to change the port number on which my site is running when debugging from Visual Studio. I am using Visual Studio 2012, and I am using ASP.NET MVC 4 for my projects, I want to change the port. Random port or fixed someone will work, just want to change the port.

+92
c # asp.net-mvc visual-studio-2012 asp.net-mvc-4 iis-express
Jan 18 '14 at 10:31
source share
9 answers

To specify a port for a web application project that uses IIS Express

  1. In Solution Explorer, right-click the name of the application and select Properties. Click the Internet tab.

  2. In the "Servers" section of the "Use a local IIS web server" section, in the "Project URL" field, change the port number.

  3. To the right of the Project URL field, click Create Virtual Directory and click OK.

  4. From the File menu, select Save Selected Items.

  5. To check the change, press CTRL + F5 to start the project. The new port number appears in the address bar of the browser.

How to: specify the port for the development server (backup archive.org here ).

+115
Jan 18 '14 at 10:34
source share

Here's a more manual method that works for both website projects and web application projects. (You cannot change the project URL from Visual Studio for website projects.)

Web Application Projects

  1. In Solution Explorer, right-click the project and select Upload Project .

  2. Browse to the IIS Express ApplicationHost.config file. By default, this file is located in:

    %userprofile%\Documents\IISExpress\config

    In recent versions of Visual Studio and web application projects, this file is located in the solution folder in the [Solution Dir]\.vs\config\applicationhost.config folder (note that the .vs folder is a hidden item)

  3. Open the ApplicationHost.config file in a text editor. In the <sites> section, find the name of your site. In the <bindings> section of your site you will see this element:

    <binding protocol="http" bindingInformation="*:56422:localhost"/>

    Change the port number (56422 in the example above) to any other. eg:

    <binding protocol="http" bindingInformation="*:44444:localhost"/>

    Bonus: You can even bind to a different host name and do cool things like

    <binding protocol="http" bindingInformation="*:80:mysite.dev"/>

    and then map mysite.dev to 127.0.0.1 in the hosts , and then open your website with " http://mysite.dev "

  4. In Solution Explorer, right-click the project and select Update Project .

  5. In Solution Explorer, right-click the project and select Properties.

    • Select the Internet tab.

    • In the "Servers" section of the "Use a local IIS web server" section, in the "Project URL" field, enter the URL that matches the host name and port that you specified in the ApplicationHost.config file earlier.

    • To the right of the project URL field, select Create virtual directory. If you see a success message, then you did everything right.

    • From the File menu, select Save Selected Items.

Site Projects

  1. In Solution Explorer, right-click on the project name and select " Delete" or " Delete" ; don't worry, this removes the project from your solution, but does not delete the corresponding files on disk.

  2. Follow step 2 above for web application projects.

  3. In Solution Explorer, right-click the solution, select Add, and then select Existing Web Site .... In the Add Existing Web Site dialog box, make sure the Local IIS tab is selected. In the "IIS Express Sites" section, select the site for which you changed the port number, and click "OK."

Now you can access your website from your new host / port name.

+60
Mar 05 '14 at 18:47
source share

Right click on the MVC project. Go to the "Properties" section. Go to the Internet tab.
Change the port number in Project Url. Example. local: 50645
Changing the bold number, 50645, to anything else will change the port on which the site is running.
Click the Create Virtual Directory button to complete the process.

See also: http://msdn.microsoft.com/en-us/library/ms178109.ASPX

Image shows MVC project web tab enter image description here

+15
Jan 18 '14 at 12:50
source share

.Net core

For those looking for this configuration in .Net core , it is located in lauchSettings.json . Just edit the port in the "applicationUrl" property.

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 graphical interface by double-clicking the "Properties" of the yor project.

Note. I had to reopen VS to make it work.

+15
Jun 17 '16 at 19:02
source share

Another fix for those who have IIS installed:

Create a path on the IIS server and place your website / application there.

Go to the researcherโ€™s solution options, then before using iisexpress from the visual studio, have vs use your own IIS.

Solution Proprieties

+2
Jan 6 '16 at 16:18
source share

You can first run IIS express from the command line and provide it with a port with / port: port-number, see other options .

+2
Nov 07 '17 at 15:04
source share

If we are talking about a website, not a web application, my problem was that the real .sln folder was somewhere else than the website, and I did not notice. Find the .sln path and then the .vs folder (hidden).

+1
Jun 11 '19 at 10:54 on
source share

Modify the .sln file using an editor such as notepad.

Replace all ports with the new port.

-3
Sep 02 '16 at 8:04 on
source share

Deploy the application in IIS with the default port. Try debugging it using visual studio. Good practice. If you use a visual studio, it will continue to change the port number most of the time. Itโ€™s better to first deploy the application in IIS and open it in visual studio and Debug it.

-6
Jan 18 '14 at 12:39 on
source share



All Articles