ASP.NET MVC3:调试和发布应用程序设置不工作 [英] ASP.NET MVC3: Debug and Release app settings not working

查看:151
本文介绍了ASP.NET MVC3:调试和发布应用程序设置不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的调试和发布不被正确读取web.config中的应用程序设置。

My debug and release web.config app settings are not being read correctly.

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

Web.Debug.config

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

Web.Release.config

Web.Release.config

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

不过,美其名曰:

However, calling:

WebConfigurationManager.AppSettings["ErrorEmailAddress"]

时,返回null(调试时)。

is returning null (when debugging).

我曾尝试加入XDT:转换=插入例如

I have tried adding xdt:Transform="Insert" e.g.

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

任何想法?

推荐答案

好吧,我想通了。

在这里找到答案:<一href=\"http://stackoverflow.com/questions/3305096/how-can-i-use-web-debug-config-in-the-built-in-visual-studio-debugger-server\">How我可以使用Web.debug.config在内置Visual Studio调试服务器?

所以,当你发布配置文件只相结合,而不是当您运行针对本地服务器。 pretty愚蠢IMO,当别人将你曾经使用Web.Debug.config?

So the config files are only combined when you publish, not when you are running against a local server. Pretty stupid IMO, when else would you ever use Web.Debug.config?

我将做的是在这里建议:<一href=\"http://stackoverflow.com/questions/3922291/use-visual-studio-web-config-transform-for-debugging\">Use Visual Studio中的web.config变换调试

I will do as is suggested here: Use Visual Studio web.config transform for debugging

,只是有作为的Web.config我的默认调试配置文件,然​​后有释放的时候发布。不能看到Web.Debug.config一个用作了这一点。

and just have Web.config as my default debugging config file, then have release for when releasing. Can't see a use for Web.Debug.config as this point.

不过,因为大多数我的设置我想对所有的环境中设置的一种方式,但开发时(如在的customErrors),这是烦人。这意味着我必须设置它们在Web.config中进行调试,然后在我的所有其他环境CONFIGS更改。

Still, this is annoying because most of my settings I want to be set one way for all environments but when developing (eg customErrors On). This means I have to set them in Web.config for debugging, then in all my other environment configs change them.

谢谢大家的响应。

这篇关于ASP.NET MVC3:调试和发布应用程序设置不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆