天道酬勤,学无止境

appsettings

How do you put environmental variables in web.config?

问题 我目前正在关注这些教程,我想从 Azure 的 Web 应用程序设置中调用明文字符串。 我的印象是环境变量用于非配置文件。 但是,我想对 web.config 文件使用相同的方法。 <connectionStrings configSource="/config/ConnectionStrings.config"> <add name="DefaultConnection" connectionString="@Environment.GetEnvironmentalVariable('SQLAZURECONNSTR_DefaultConnection')" providerName="System.Data.SqlClient" /> </connectionStrings> <appSettings file="config\AppSettingsSecret.config"> <!-- Code Removed for Conciseness--> <add key="mailAccount" value="@Environment.GetEnvironmentalVariable('APPSETTING_mailAccount')" /> <add key="mailPassword" value="@Environment

2022-05-10 17:48:35    分类:技术分享    asp.net-mvc   azure   web-config   connection-string   appsettings

AppSettings in markup issue

问题 我试图把它放在我的标记中: <script type="text/javascript" src="<%$ AppSettings:proxyScriptUrl %>"></script> 但由于某种原因,这不被接受。 我在这里做错了什么? 要求是我不使用辅助方法,而是在标记中使用表达式构建器。 回答1 根据文档,这是不允许的: 如果要将表达式用作页面或控件上的静态值,请将表达式用作 ASP.NET 服务器控件的一部分。 一个典型的策略是添加一个 Literal 控件并将其 Text 属性设置为一个表达式。 例如,要将版权声明放在每个页面的底部,您可以使用以下内容: <p align="center"> <asp:Literal runat="server" text="<%$ AppSettings: copyright %>"/> </p> 如果想在 aspx 文件中完成所有操作,这可能会对您有所帮助: <script type='text/javascript' src='<asp:Literal id="literal1" runat="server" text="<%$ AppSettings: jsSource %>" />'></script> 请注意文本变量中令人不快的单引号 - 尝试对我们进行转义的双引号会导致“脚本标签格式错误”错误。 编辑:道歉 -

2022-05-05 23:10:04    分类:技术分享    asp.net   appsettings

How to convert AppSettings.json to Advance Azure Settings with C#?

Did you notice that Azure upgraded the AppSettings Management? Now it s possible to update multiple AppSettings in one shot using the Advanced Edit Options, but the formating is not the same as AppSettings.json. I m looking for a quick solution to convert my AppSettings section to Azure Advance Edit options format. Do you know how to do that? So this: "Simulation": { "ApiUrl": "YourApiUrl", "ApiKey": "YouApiKey", "Groups": [ { "Name": "YourGroup", "Latitude": 45.50884, "Longitude": -73.58781, "Radius": 500 } ], "Planifications": [ { "GroupName": "YourGroup", "At": "07:00", "Status": 10 } ] }

2022-05-02 06:35:24    分类:问答    azure   .net-core   appsettings

How does one Transform AppSettings in ASP.NET Core

I was led to believe that appsettings.json and its environment counterparts (dev, staging, production) replaced Web.config transforms. This works fine in a dev environment, where variables for those environments exist in the launchSettings.json However, if I use the Publish feature, configuring the Publish to use the Staging build configuration which I created, no transform appears. I've read elsewhere that you need to create Environment variables. Really! Is that what it has come to? We now have an armada of System Environment variables for Applications which may or may not (over time) be

2022-04-30 14:22:16    分类:问答    c#   asp.net-core   asp.net-core-2.1   appsettings

How do you put environmental variables in web.config?

I am currently Following these tutorials, and I am wanting to call the clear text string from Azure's Application Settings for Web Apps. I am under the impression that environmental variables are used for non-config files. However, I am wanting to use the same methodology for web.config files. <connectionStrings configSource="/config/ConnectionStrings.config"> <add name="DefaultConnection" connectionString="@Environment.GetEnvironmentalVariable('SQLAZURECONNSTR_DefaultConnection')" providerName="System.Data.SqlClient" /> </connectionStrings> <appSettings file="config\AppSettingsSecret.config">

2022-04-28 23:13:07    分类:问答    asp.net-mvc   azure   web-config   connection-string   appsettings

AppSettings in markup issue

I am trying to put this in my markup: <script type="text/javascript" src="<%$ AppSettings:proxyScriptUrl %>"></script> But for some reason this is not accepted. What am I doing wrong here? The requirement is that I do not use a helper method but that the expressionbuilder is used in the markup.

2022-04-28 03:08:43    分类:问答    asp.net   appsettings

How to Deploy Different App Settings for different Environments on Azure

I want to run different app settings on different environments using Microsoft Azure in visual studio 2015. for Local Environment: <add key="EnvironmentPath" value="http://local:12345" /> for QA: <add key="EnvironmentPath" value="http://qa.abc.com" /> for staging: <add key="EnvironmentPath" value="http://staging.abc.com" /> And it automatically load its specific value in each environment. like in HTML Template <a href="appsettings["EnvironmentPath"]"></a> Any help.

2022-04-28 00:48:48    分类:问答    c#   asp.net-mvc   appsettings   web.config-transform

Override App.config value with an environment variable

I have a C# console program that prints an App.config value. Can I override this value from an environment variable? In my real use-case, the value specifies a port to bind, and I need to run multiple instances of the program in my Jenkins server, so each one should have a different value even though they use the same config file. Example App.config: <appSettings> <add key="TestKey" value="Foo"/> </appSettings> Example Code: Console.WriteLine($"Key: {ConfigurationManager.AppSettings["TestKey"]}"); I tried just setting the Key name but that obviously doesn't work: c:\Workspace\ConsoleApp2

2022-04-27 12:58:28    分类:问答    c#   environment-variables   appsettings

How to update appSettings in a WPF app?

问题 祝福大家! 这是我在stackoverflow上的第一个问题。 我有一个 WPF 应用程序,正在为我部门的其他开发人员编写,有几个设置需要在启动时检查并在未设置时更新(一个是用户可执行文件的位置电脑,我们都有,只是不在同一个地方)。 所以当我的应用程序第一次启动时,我需要弹出一个文件选择器让他们选择位置。 我需要做的就是将它的位置写到 appSettings 中,但我似乎无法得到它,我昨晚非常努力地搜索了谷歌,试图找到一种方法。 我看到的大多数答案都涉及将 app.config 文件作为直接 XML 读取,这似乎不对。 所以,我只需要一种方法来更新我的应用程序的 appSettings 中的值。 我可以很好地阅读它们,只是还没弄清楚如何给它们写信。 非常感谢! 詹姆士 回答1 您是否查看过 ConfigurationManager 类? 它为 app.config 文件提供了更强大的接口,您可以执行以下操作: Configuration oConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); oConfig.AppSettings.Settings["PreferenceToRemember"].Value = "NewValue"; oConfig.Save

2022-04-21 03:01:42    分类:技术分享    wpf   appsettings