加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – ASP.NET MVC3:调试和发布应用程序设置不工作

发布时间:2020-12-15 18:44:29 所属栏目:asp.Net 来源:网络整理
导读:参见英文答案 How can I use Web.debug.config in the built-in visual studio debugger server?7个答案我的调试和发布web.config应用程序设置未正确读
参见英文答案 > How can I use Web.debug.config in the built-in visual studio debugger server?7个答案我的调试和发布web.config应用程序设置未正确读取。

Web.config:

<appSettings>
 <add key="webpages:Version" value="1.0.0.0"/>
 <add key="ClientValidationEnabled" value="true"/>
 <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>

Web.Debug.config

<appSettings>
    <add key="ErrorEmailAddress" value="developerEmail@email.com" />
    <add key="TestModeEmailAddress" value="developerEmail@email.com" />
</appSettings>

Web.Release.config

<appSettings>
    <add key="ErrorEmailAddress" value="prodErrorEmail@email.com" />
</appSettings>

但是,呼叫:

WebConfigurationManager.AppSettings["ErrorEmailAddress"]

返回null(调试时)。

我已经尝试添加xdt:Transform =“Insert”例如

<add key="ErrorEmailAddress" value="prodErroEmail@email.com" xdt:Transform="Insert" />

有任何想法吗?

解决方法

好吧,我想出来了

这里回答:How can I use Web.debug.config in the built-in visual studio debugger server?

所以配置文件仅在您发布时才组合,而不是当您在本地服务器上运行时。相当愚蠢的海事组织,你还能否使用Web.Debug.config?

我会按照这里建议:Use Visual Studio web.config transform for debugging

并将Web.config作为我的默认调试配置文件,然后释放时释放。作为这一点,看不到用于Web.Debug.config的用法。

尽管如此,这是令人讨厌的,因为我想要为所有环境设置一个方法,但是开发时(例如customErrors On)。这意味着我必须将它们设置在Web.config中进行调试,然后在所有其他环境配置中更改它们。

感谢大家的回应。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读