【问题标题】:build application sucess message changed after published发布后构建应用程序成功消息已更改
【发布时间】:2016-10-20 09:12:50
【问题描述】:

我有一个 Web 应用程序并开发了一些 API。每当 API 成功时,我都会传递一条消息。我想在发布此应用程序更改消息后进行更改。所以我想知道如何像这样开发。

【问题讨论】:

标签: c# model-view-controller asp.net-web-api


【解决方案1】:

最简单的方法是在 web.config 文件中添加一个标志,例如添加这个键:

<appSettings><add key="IsDebug" value="True" /></appSettings>

并将此密钥添加到 Web.Release.config 文件中:

<appSettings><add xdt:Transform="SetAttributes" xdt:Locator="Match(key)" key="IsDebug" value="False" /></appSettings>

然后你可以在你的代码中勾选“IsDebug”键,例如:

  NameValueCollection appSettings = ConfigurationManager.AppSettings;
string isDebug = appSettings["IsDebug"]);
if(isDebug == "True")
{
// your debug version message
}
then
{
// your release version message
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 2021-09-26
    • 1970-01-01
    • 2022-11-11
    • 2011-08-13
    相关资源
    最近更新 更多