如何转义 .env 文件中的 = 符号

发布于 2025-01-14 17:48:10 字数 700 浏览 2 评论 0原文

我尝试使用 .env 文件创建应用程序配置,首先我可以获得此配置的变量值。

APPLICATION_NAME=MyApps
LOGGING__LOGLEVEL__DEFAULT=Warning
PROPERTY=value

结果: 结果 1

但是,当我尝试将 ConnectionString 变量添加到 .env 文件时。运行我的应用程序时,此变量的值始终返回 null

CONNECTIONSTRINGS__CONN=Database=master;Server=(local);Integrated Security=SSPI;

Result : 结果 2

我认为 Database=master;Server=(local) 上的 = 符号 将检测为命令。谁能帮我解释为什么会发生这种情况,以及如何转义 .env 文件中的 = 符号?

I try to create an application configuration with .env file, for the first I can get the value of variables for this config.

APPLICATION_NAME=MyApps
LOGGING__LOGLEVEL__DEFAULT=Warning
PROPERTY=value

Result :
Result 1

But, when I try to add ConnectionString variable to .env file. And running my application, the value for this variable always returns null

CONNECTIONSTRINGS__CONN=Database=master;Server=(local);Integrated Security=SSPI;

Result :
Result 2

I think the = symbol on Database=master;Server=(local) will detect as a command. Can anyone help me to explain why this happens, And how to escape the = symbol in .env file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文