0

I am working on an angular project in visual studio.

I have created a Blank solution visual studio then added the existing website.

Open VS>>New Project>>Blank Solution>>Right click solution>>Add existing web site>>select Folder>>F5

Due to some reason I have to run the website on the localhost:8080 but the visual studio is setting the port itself.

How to change the running port to 8080

I have googled a lot but the only solutions I found is for ASP.net. like stackover flow, microsoft docs

Alt+Enter is opening this property window

enter image description here

enter image description here

Community
  • 1
  • 1
Vikas Bansal
  • 8,685
  • 14
  • 51
  • 84

2 Answers2

6

You can change the port in the Properties page of the project.

Right click the project and go to Properties or Alt + Enter.

Properties > Web.

Under Servers section, select "Specific Port" and provide one. :)

Sooraj
  • 197
  • 1
  • 2
  • 9
  • The property window does not have the `Web` option. Please check the screen shot in the question @sooraj – Vikas Bansal Mar 16 '16 at 07:58
  • this works for me.. right click project, select properties and there's a web subcategory there, select that and then you will find Servers where you can set project URL. – sd4ksb Jul 01 '19 at 20:47
  • It's important to right click the *project*, not the *solution*. There, you can change the URL. Often, the solution is at the top, the project(s) are below that level. – mneumann May 18 '20 at 16:25
1

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


Community
  • 1
  • 1
Rajshekar Reddy
  • 17,202
  • 3
  • 34
  • 54