16

I have a C# Asp.net web project made in Visual Studio. The project runs on a certain port (57243) and I made other programs that were testing the web service etc to use "localhost:57243".

Recently I tried running the project in Jetbrains' Rider IDE because of whatever reasons I made up at the time. The only issue I am having now is that the web service runs on port 5001 and I cannot find any property to change the base url or the host port to make it work.

TLDR, I am looking for this option inside the Jetbrains' Rider IDE: enter image description here

Wietlol
  • 1,001
  • 1
  • 10
  • 25

6 Answers6

29

This can be done inside the Rider IDE if you like.

If you edit the run/build configuration you are using when you hit F5 and then edit the environment variables you can add the ASPNETCORE_URLS environment variable which will run the app using the port specified as shown here.

Rider Run configuration environment variables

Steps to edit the setting

  1. Open the edit screen for the run/build configuration
  2. Click the ellipsis on the environment variables edit box to edit
  3. Click the plus (+) symbol to add a new evironment variable
  4. Set the name to ASPNETCORE_URLS and the value to http://*:57243
  5. Save your changes and run
Sasquatch
  • 306
  • 2
  • 5
17

@Sasquatch's answer works for ASP.NET Core only.

For plain old ASP.NET, with IIS Express, we can go the project properties, Web section, and then

  • Make sure "Server type:" is "IIS Express".
  • Check "Generate applicationhost.config". [*]
  • Set "URL:" to "localhost".
  • Set "Development port:" to whichever port you want ("1234" in this example).
  • Click "OK" and restart the web application.

enter image description here

This will rewrite the generated applicationhost.config file (in .idea\config\ folder) with your selected configuration.

[*] If "Generate applicationhost.config" is unchecked, you should edit that file directly, like @WWietlol's answer suggests.

rsenna
  • 11,775
  • 1
  • 54
  • 60
  • 2
    Thank you! This was the only solution that has worked for me! My runner was ignoring all of the profiles and launchSettings.json settings. – Justin Anthony Aug 29 '19 at 17:45
7

It turned out that the option in Visual Studio just changes the application.config in the .vs folder. A similar file in the .idea folder had the properties of the ports.

Changing it in that file fixed it.

Wietlol
  • 1,001
  • 1
  • 10
  • 25
6

To set the Port on JetBrain Rider v2019.1, in the solution view, open the launchSettings.json file in the Solution > Project > Properties folder. You will be able to set the applicationUrl port for both the https://localhost:{port} and http://localhost:{port}.

Make sure you restart the that app, to use the new port.

LaunchSettings.json

SammyRNYCreal
  • 701
  • 6
  • 6
0

Removing all files in the .idea folder helped me. Rider showed me the initial window of to configure my project from scratch and imported all necessary settings (like environment and url) automatically.

Liam Kernighan
  • 2,335
  • 1
  • 21
  • 24
0

I was unable to configure a root as per rsennas answer with an ASP.NET MVC project.

Neither Rider nor Visual Studio control the configuration of the web server (IIS Express), instead they both just generate an applicationhost.config file that they pass to IIS Express. You should see something like this when you start the application from Rider

C:/Program Files/IIS Express/iisexpress.exe "/config:C:/foo/.idea/config/applicationhost.config" "/site:foo" /apppool:Clr4IntegratedAppPool
Starting IIS Express ...

to spot which applicationhost.config file is used. Specifically, the relevant section looks (ish) like this

<site name="WebSite1" id="1" serverAutoStart="true">
  <application path="/">
    <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
  </application>
  <!-- ... -->
</site>

Unfortunately, neither Rider nor Visual Studio is particularly good at generating this file. Rider tends to yield incorrect configurations and Visual Studio tends to be inconsistently formatted ¯\_(ツ)_/¯

You can use a diff-tool (like vimdiff) to compare the two (preferably after harmonizing the formatting) and pull the relevant configurations from one file to the other.

Specifically, it appears IIS Express requires a root website. In my case I had to change something like this

<site name="foo" id="1" serverAutoStart="true">
  <application path="/foo">
    <virtualDirectory path="/" physicalPath="C:/Foo" />
  </application>
</site>

into

<site name="foo" id="1" serverAutoStart="true">
  <application path="/">
    <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
  </application>
  <application path="/foo">
    <virtualDirectory path="/" physicalPath="C:/Foo" />
  </application>
</site>
CervEd
  • 3,306
  • 28
  • 25