在web.config中读取环境变量

时间:2022-08-27 23:14:26

Is there a way write code in web.config file using preprocessed function. Say I created environment variables like %Temp%, %WINDIR%. order to read these I can use the configurationManager class. But I dont want to use it. I woudl like to use a preprocessed function similar to timeStampPattern="{timestamp(local)}". Here timestamp(local) retrieves the value directly. So in a similar way can i read the environment variables %temp% and %windir% using preprocessed function if any exists?

是否有办法在网上写代码。使用预处理函数配置文件。假设我创建了环境变量,如%Temp%、%WINDIR%。要阅读这些,我可以使用configurationManager类。但我不想用它。我喜欢使用类似于timeStampPattern=“{timestamp(local)}”的预处理函数。在这里,时间戳(本地)直接检索值。因此,如果存在环境变量%temp%和%windir%,我可以用类似的方式读取它们吗?

3 个解决方案

#1


2  

No. There's no way to do this.

不。这是不可能的。

#2


1  

Are you looking for Environment.getenvironmentvariable()? You will need to find and replace them yourself.

你在寻找环境。getenvironmentvariable()吗?你需要自己找到并替换它们。

#3


1  

It can be done.

这是可以做到的。

That is all you need to do: value="${envVarKey}

这就是您需要做的:value=“${envVarKey}”

where envVarKey any environment variable.

其中envVarKey任何环境变量。

#1


2  

No. There's no way to do this.

不。这是不可能的。

#2


1  

Are you looking for Environment.getenvironmentvariable()? You will need to find and replace them yourself.

你在寻找环境。getenvironmentvariable()吗?你需要自己找到并替换它们。

#3


1  

It can be done.

这是可以做到的。

That is all you need to do: value="${envVarKey}

这就是您需要做的:value=“${envVarKey}”

where envVarKey any environment variable.

其中envVarKey任何环境变量。