Target wise Server Actions Globals?

Would like to configure the Globals inside of Server Actions to be specific to a target - just like we can do with the DB connections.

Have tried to change the target and save the Globals for each one separately - but it seems to remain common for all targets.
How can we set these for each target separately? Or it is not yet possible with Wappler?

Only the global settings like connections are separately saved per target, but not the global action itself

Ok. Will add a feature request for it.
Between dev and prod - such a setup will come in very handy.

Usually you use environment variables to setup target specific settings.

Isn’t that what you want?

We are calling a lot of APIs. The url varies between dev and prod. Also the Auth key that goes into headers also vary from dev to prod.

You think this can be done via env variables?

Yes that is exactly the things that are usually controlled by environment variables. So different api endpoints, database settings, credentials etc

Thanks for the guidance, will look into it.

ours is a ASP.net project.
our .net expert has confirmed that environmentVariables are not avialable for .net.
it is only available for .net Core.

what do you think now @George - would you consider this request at least for .net projects n Wappler?

Maybe this helps:

the ASP.Net expert guy did point us to here:
asp.net mvc - How do you put environmental variables in web.config? - Stack Overflow

but am not so sure how to config this in Server Actions in Wappler?

Had seen that doc - it sets for AppPool so i didn’t bother - but will try to set that manually in web.config and see if Wappler’s $_ENV is able to read it!

How is Wappler configured to read $_ENV for ASP.Net?

well just add their names under $_ENV and you can use them everywhere!

And if you define them in the global action - then they will be available in all server actions

taking a cue from here: https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/environmentvariables/ we tried following 2 configs:

<applicationPools>
   <add name="My App Pool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic">
      <environmentVariables>
         <add name="SomeURL" value="https://domain.com"/>
      </environmentVariables>
   </add>
</applicationPools>
<system.applicationHost>
<applicationPools>
   <add name="My App Pool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic">
      <environmentVariables>
         <add name="SomeURL" value="https://domain.com"/>
      </environmentVariables>
   </add>
</applicationPools>
</system.applicationHost>

both were added in web.config under the <configuration> tag.

this actually broke IIS and the website is not even working anymore!

have you guys been able to successfully use environment variables with ASP.Net project?
what does you web.config looks like in such case - can you please share so that we can replicate and get this done at our end as well?

Thank you.

This just creates a variable. How do we set the value of these variables?

I tried the link you shared about Environment Variables, and was able to add them to IIS/Application Pool. But not able to access those env variable values in Wappler. Can you please explain how to do that?
The example given in the link is for C# so not applicable for a Wappler project.

As per your replies, what I was expecting is that once we set env variables in IIS/Application Pool, the $_ENV would have those values available automatically. But that does not seem to be the case.

What we are after here is being able to use ENV variables on client & server side both, just like in NodeJS.
For server, we can use $_ENV...
For client, we can use <%= $_ENV... %>

any luck here @George?

Setting environment variables is done usually on the server self.

For node and docker deployments- usually tge control panels have possibilities to add environment variables.

For asp.net you should refer the Microsoft docs

Say we do that. Is there a way to access them in Wappler? $_ENV does not seem to be working.

$_ENV reads the available environment variable from the server. If it doesn’t return a value it means those are not set.

You might want to output the whole $_ENV without a key, to see all the set environment variables

Have set the variables as per MS Docs. From the link you shared.
Able to access env variables as per the C# example code, in a VS project, but not working on Wappler.

If you guys could share an example of setting env variables in IIS ASP.NET project and using them in Wappler, it would solve our problem.

any update on this please?