为什么我必须强制 blazor 服务器应用程序通过 web.config 而不是 appsettings.X.json“确认”ASPNETCORE_ENVIRONMENT

问题描述 投票:0回答:1

我使用 smarterasp.net 作为网络主机。我使用他们的控制面板在我的临时服务器上设置 ASPNETCORE_ENVIRONMENT (使用池管理器)。我的 appsettings.Staging.json 文件具有正确的连接字符串(通过 4 种不同的方式验证)。但是,我的程序无法读入它。

如果我破解了发布过程中自动生成的 web.config 文件,那么我可以让它从 appsettings.Staging.json 读取连接文件。这既黑客又危险......

同样的事情也发生在本应是生产服务器的地方。这是该问题的 web.config hack:

<aspNetCore processPath="dotnet" arguments=".\TimeReward.Server.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess">
    <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Release" />
    </environmentVariables> 
</aspNetCore>
.net-core web-hosting appsettings
1个回答
0
投票

正如你所说,将连接字符串存储在 web.config 和 appsetting.json 中不够安全。

对于这个事情,我建议你可以考虑使用Azure Key Vault来存储这些设置。

您冷设置了 Azure 密钥保管库和项目内的所有设置,它只包含到 Azure 密钥保管库的连接字符串。通过使用它,您可以避免在 web.config 或 appsetting.json 中显示连接字符串,以提高应用程序的安全性。

更多详情,可以参考这篇文章

© www.soinside.com 2019 - 2024. All rights reserved.