如何Web.debug.config在visual studio 2010内置调试器中合并和使用?
我的调试和发布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>
Run Code Online (Sandbox Code Playgroud)
Web.Debug.config
<appSettings>
<add key="ErrorEmailAddress" value="developerEmail@email.com" />
<add key="TestModeEmailAddress" value="developerEmail@email.com" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
Web.Release.config
<appSettings>
<add key="ErrorEmailAddress" value="prodErrorEmail@email.com" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
但是,致电:
WebConfigurationManager.AppSettings["ErrorEmailAddress"]
Run Code Online (Sandbox Code Playgroud)
返回null(调试时).
我试过添加xdt:Transform ="Insert"例如
<add key="ErrorEmailAddress" value="prodErroEmail@email.com" xdt:Transform="Insert" />
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
有没有办法在Web部署之外应用VS 2010 Web.Config转换,比如说在调试期间?能够在不同环境之间自由切换,这将给我一个很大的推动力.
我有一个带有三个web.config转换的asp.net应用程序.

我正在考虑当我启动调试运行(选择了调试模式的F5)时,Web.Debug.config中写入的转换将适用..但它不起作用..使用的Web.config是"Base".
您将告诉我:"转换不正确"..但它们是因为当我使用调试版本配置进行部署(右键单击/发布)时:

渲染的web.config有修改!所以它工作,但调试运行使用基础web.config ..有一个地方,我可以配置?
我正在尝试使用Web Setup Project部署应用程序.我遇到的问题是web.config文件永远不会被转换.根据这篇文章的设计,转换只发生在发布期间.如果依次构建安装项目调用其他程序集构建命令,如何正确更新web.config属性?
我正在尝试按照此处所述进行web.config转换.我们已经在其他项目中使用了这种方法,它没有问题,但在这个新项目上没有.
这是我试过没有成功的测试
我已经多次阅读了上面的链接和这个相关的堆栈问题,但看不出是什么问题.
注意发布转换确实有效.它创建一个web.template.xml文件,其中包含来自web.template.Test.xml的值,但不会像wpp.targets指示的那样创建web.config.xml.因此,这似乎是让构建转换正常工作的问题.
任何人都知道缺少什么?
wpp.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Make sure web.config will be there even for package/publish -->
<Target Name="CopyWebTemplateConfig" BeforeTargets="Build">
<Copy SourceFiles="web.template.xml"
DestinationFiles="web.config"/>
</Target>
<PropertyGroup>
<PrepareForRunDependsOn>
$(PrepareForRunDependsOn);
UpdateWebConfigBeforeRun;
</PrepareForRunDependsOn>
</PropertyGroup>
<!-- This target will run right before you run your app in Visual Studio -->
<Target Name="UpdateWebConfigBeforeRun">
<Message Text="Configuration: $(Configuration): Web.template.$(Configuration).xml"/>
<TransformXml Source="web.template.xml"
Transform="web.template.$(Configuration).xml"
Destination="web.config" />
</Target>
<!-- Exclude the …Run Code Online (Sandbox Code Playgroud) 我的Microsoft.ApplicationInsights物体有问题。每次代码第一次碰到这些对象中的一个,初始化时间就非常长(有时甚至是40秒左右)。
范例1:
范例2:
如此长的首次加载的原因是什么?我怎样才能解决这个问题?
我想在项目生产(发布模式)时显示自定义错误页面,并在(调试模式)运行页面时显示asp.net的默认错误页面.
我的项目中有三个Web.config文件.
这是我尝试但没有运气.
Web.config文件
<customErrors mode="On" defaultRedirect="~/Home/Error">
<error statusCode="404" redirect="~/Home/Error" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)
Web.Debug.config
<customErrors mode="Off" xdt:Transform="Replace"></customErrors>
Run Code Online (Sandbox Code Playgroud)
Web.Release.config
<customErrors mode="On" defaultRedirect="~/Home/Error">
<error statusCode="404" redirect="~/Home/Error" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)
有谁知道我怎么做到这一点?
提前致谢 :)
编辑: 阅读后,我认为这是一个已知的错误,但我无法找到错误的修复程序.如果有人对此有更多了解,请分享.谢谢