Changing Project Port Number in Visual Studio 2013

Changing project port number in Visual Studio 2013

There are two project types in VS for ASP.NET projects:

Web Application Projects (which notably have a .csproj or .vbproj file to store these settings) have a Properties node under the project. On the Web tab, you can configure the Project URL (assuming IIS Express or IIS) to use whatever port you want, and just click the Create Virtual Directory button. These settings are saved to the project file:

<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<DevelopmentServerPort>10531</DevelopmentServerPort>
...
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>

Web Site Projects are different. They don't have a .*proj file to store settings in; instead, the settings are set in the solution file. In VS2013, the settings look something like this:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebSite1(1)", "http://localhost:10528", "{401397AC-86F6-4661-A71B-67B4F8A3A92F}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.5"
...
SlnRelativePath = "..\..\WebSites\WebSite1\"
DefaultWebSiteLanguage = "Visual Basic"
EndProjectSection
EndProject

Because the project is identified by the URL (including port), there isn't a way in the VS UI to change this. You should be able to modify the solution file though, and it should work.

How can I change IIS Express port for a site

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 then select Properties.
    Click the Web tab.

  2. In the Servers section, under Use Local IIS Web server, in the Project URL box change the port number.

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

  4. In the File menu, click Save Selected Items.

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

From How to: Specify a Port for the Development Server (archive.org backup here).

Visual studio 2013: Manually specify localhost port no. for website project

You can't change the project URL from within Visual Studio for Website projects.

There are two working methods for me, Posting this answer after testing.

First Option

Web Site Projects don't have a .*proj file to store settings instead, the settings are set in the solution file. In VS2013, the settings look something like this:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "TestWebSite", "http://localhost:56422", "{401397AC-86F6-4661-A71B-67B4F8A3A92F}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.5"
...
SlnRelativePath = "..\..\WebSites\WebSite1\"
DefaultWebSiteLanguage = "Visual Basic"
EndProjectSection
EndProject

Because the project is identified by the URL (including port), there isn't a way in the Visual studio UI to change this. You should be able to modify the solution file though, and it should work.

Note: In your case to set the port to 8080 you must open visual studio in Run as Administrator mode. You MUST run Visual Studio as an administrator in order to open websites with a port less than 1000

Credit of this option goes to Jimmy and original answer is here


Second Option

To specify a port for any web site project that uses IIS Express:

  1. First Add the existing website and run it once. So that it gets assigned in the IIS sites list.

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

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

    %systemdrive%\Users\<YourWindowsUsername>\Documents\IISExpress\config

  4. Open the ApplicationHost.config file in a text editor. In the <sites> section, search for your site's name. In the <bindings> section of your site, you will see an element like this:

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

    Change the port number (56422 in the above example) to anything you want. e.g.:

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

    and then map mysite.dev to 127.0.0.1 in your hosts file, and then open your website from "http://mysite.dev"; but that's outside the scope of this answer so I won't go into any more details)

  5. 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 that the Local IIS tab is selected. Under IIS Express Sites, select the site for which you have changed the port number, then click OK.

Now you can access your website from your new hostname/port.

Credit of this option goes to Saeb Amini and the original answer is here


Where can I change the port of a Web Site Project (WCF) in Visual Studio 2013?

it is as suspected. The ports have to be changed in the SLN file and the URL in the web.config

SLN File of the solution:

VWDPort = "xxx"

Web.config of the website:

endpoint address="http://....."

Why and how to fix? IIS Express The specified port is in use

i solve the problem this way...

File -> Open -> Web Site...
Sample Image

After that select Local IIS under IIS Express Site
remove the unwanted project.

hope this help.

How do I change the debug port in Visual Studio 2017?

For me, I was able to find it with the following steps in Visual Studio 2017:

  1. Right click on the web project, then click Properties.
  2. Click on the Debug tab.
  3. Under the Profile IIS Express, you will find the port at the App URL box.

Setting a static port number for Web Site (not Web Application Project) in Visual Studio 2013

For 2015, I posted my answer here: https://stackoverflow.com/a/43698869/1831054

Basically, I just did a file-search for files containing the "taken" port number, and replaced where necessary. May be different for 2013 or other versions.

Setting static port number on Visual Studio Dev Server with a WebSite project

To specify a port for the ASP.NET Development Server - WebSite / WebServices projects

  1. In Solution Explorer, click the name of the application.
  2. In the Properties pane, click the down-arrow beside Use
    dynamic ports
    and select False from
    the dropdown list. This will enable
    editing of the Port number property.
  3. In the Properties pane, click the text box beside Port number and type
    in a port number. Click outside of
    the Properties pane.This saves the property settings.
  4. Each time you run a file-system
    Web site within Visual Web Developer, the ASP.NET

    Development Server will listen on the specified port.


Related Topics



Leave a reply



Submit