问题描述
在我machine.config文件我有以下
In my machine.config file I have the following
<configuration>
....
<appSettings>
<add key="key" value="value"/>
</appSettings>
</configuration>
我想通过检索它ASP页上
I am trying to retrieve it on an asp page by using
ConfigurationManager.AppSettings["key"];
和它空每次都返回。
推荐答案
您可能将其放在了错误的machine.config。记住,是.NET 2.0和3.5,因为它们都的目标CLR 2.0(相同c的machine.config:\\ WINDOWS \\ Microsoft.NET \\框架\\ V2.0.50727 \\ CONFIG \\
)和一个独立的machine.config为.NET 4.0( C:\\ WINDOWS \\ Microsoft.NET \\框架\\ v4.0.30319 \\ CONFIG \\
)
You probably put it in the wrong machine.config. Remember that there is the same machine.config for .NET 2.0 and 3.5 as they both target CLR 2.0 (c:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\
) and a separate machine.config for .NET 4.0 (c:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\
).
还要记住,如果你运行的是64位操作系统的文件夹 C:\\ WINDOWS \\ Microsoft.NET \\ Framework64 \\ V2.0.50727 \\ CONFIG \\
和 C:\\ WINDOWS \\ Microsoft.NET \\ Framework64 \\ v4.0.30319 \\ CONFIG \\分别为
。所以确保你已经把正确的machine.config中对应于您在ASP.NET应用程序的目标框架的版本,以及在x86或x64位的关键。
Also remember that if you are running a 64 bit OS the folders are c:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\
and c:\Windows\Microsoft.NET\Framework64\v4.0.30319\CONFIG\
respectively. So make sure you have put the key in the correct machine.config that correspond to the framework version you are targeting in your ASP.NET application as well as the x86 or x64 bit.
所以,你得到每CLR版本的machine.config和位数的(如果不这样的话存在的想法)。
So you get a machine.config per CLR version and bitness (no idea if such word exists).
这篇关于machine.config中的appSettings为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!