1. Bernhard Giesriegl
  2. SnapDevelop
  3. Tuesday, 24 August 2021 13:00 PM UTC

Hi all, hope this wasn't asked before:

Creating the web api sample project from snap development 2021 I get a service listening on localhost:5000. Connecting with a test program consuming on this address works fine.

When I change the IP address in launchsettings.json e.g. to 192.168.0.20:5000 and start in debug mode (Ctrl+F5), a connection via this IP works fine for the test program.

 

Publishing the project and starting the .exe file from the release directory, a connection is only possible via localhost:5000

Changing the launchsettings.json in Properties subdir of the publish directory of has no effort.

How can I change the IP for the published version?

 

Thanks for your suggestions!

Bernhard

Accepted Answer
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 25 August 2021 14:58 PM UTC
  2. SnapDevelop
  3. # Permalink

Hi Bernhard,

My apologies, I thought you were working with a PowerServer project. Sorry for the misunderstanding.

The launchSettings.json is not read when the application is run from the EXE file. In order to manually set the IP:port to bind to when running from the EXE, you need to add the property "Urls" to the appsettings.json file. The appsettings.json file WILL be read when running the EXE.

Something to keep in mind is that, as I said, the launchSettings.json file is read by the IDE only, when you run the project from inside it (and provided you set the option launchBrowser to true), the URL that will be opened will be that of the launchSettings.json file, whilst the app itself will use the URLs from the appsettings.json (or appsettings.Development.json depending on your profile) file. As such, if you're gonna use a different URL when publishing, I suggest you keep launchSettings.json and appsettings.Development.json's urls fields in sync.

Hope this helps.

 

Regards,
Francisco

Comment
There are no comments made yet.
Bernhard Giesriegl Accepted Answer Pending Moderation
  1. Wednesday, 25 August 2021 17:19 PM UTC
  2. SnapDevelop
  3. # 1

Hi Francisco,

thanks, that helped, I put the line

 

    "Urls": "https://192.168.0.20:5001;http://192.168.0.20:5000"

before the last brace
}

in the file appsettings.json and this works fine.

So I comment this as the correct answer!

Best regards, Bernhard

Comment
  1. Bernhard Giesriegl
  2. Wednesday, 1 September 2021 09:43 AM UTC
Important additional information:

You have to insert a comma before "Urls"... if you add this line to an existing configuration to separate this from the other entries

Insert:



,

"Urls": "https://192.168.0.20:5001;http://192.168.0.20:5000"

  1. Helpful
There are no comments made yet.
Bernhard Giesriegl Accepted Answer Pending Moderation
  1. Tuesday, 24 August 2021 13:58 PM UTC
  2. SnapDevelop
  3. # 2

Hi Francisco,

thanks for your reply.

Can you be more specific where I find this configuration? It's SnapDevelop, the sample creating a web API from the start page.

Regards

Bernhard

Comment
  1. Armeen Mazda @Appeon
  2. Tuesday, 24 August 2021 16:47 PM UTC
Hi Bernhard, Can you confirm are you using SnapDevelop to compile a C# REST API project you developed yourself or are you trying to compile the C# generated code from PowerServer 2021?
  1. Helpful
  1. Bernhard Giesriegl
  2. Wednesday, 25 August 2021 06:11 AM UTC
Hi Armeen,

there is a sample project "Creating a Web API" from SnapDevelop's 2021 Start page I'm working with.
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 24 August 2021 13:38 PM UTC
  2. SnapDevelop
  3. # 3

Hi Bernhard,

The correct way to change the Web API's URL is by going into your PowerServer configuration. Under the Web APIs tab, the Web API URL field specifies the URL the API will be listening on, and the URL the Installable Cloud App will try to connect to.

 After changing this field you will need to redeploy the PowerServer project.

Let me know if this helps.

Regards,
Francisco

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.