1

asp.net の C# コードから WebConfigurationManager を使用して、カスタム構成ファイル (abc.config など) から接続文字列を読み取るにはどうすればよいですか?

Configuration conf = WebConfigurationManager.OpenWebConfiguration("~/abc.config");

これはうまくいかないようです。

4

2 に答える 2

1

webconfigurationmanager で読めるとは思えません。それはxmlファイルであるため、他のxmlファイルと同じように読むことができます

public static string GetSingleValue(string strXPathExpression, string strAttributeName)
        {
            XmlNode node = GetNode(strXPathExpression);
            if (node != null)
            {
                XmlAttribute attribute = node.Attributes[strAttributeName];
                if (attribute != null)
                    return attribute.Value;
            }

            return string.Empty;


        }
于 2012-06-15T21:19:30.583 に答える