[Serializable]
public class KeyValue : ProfileBase
{
public KeyValue() { }
public KeyValuePair<string, string> KV
{
get { return (KeyValuePair<string, string>)base["KV"]; }
set { base["KV"] = value; }
}
}
public void SaveProfileData()
{
KeyValue profile = (KeyValue) HttpContext.Current.Profile;
profile.Name.Add(File);
profile.KV = new KeyValuePair<string, string>("key", "val");
profile.Save();
}
public void LoadProfile()
{
KeyValue profile = (KeyValue) HttpContext.Current.Profile;
string k = profile.KV.Key;
string v = profile.KV.Value;
Files = profile.Name;
}
我正在尝试保存KeyValuePair<K,V>
在 asp.net 用户配置文件中,它也保存了,但是当我访问它时,它显示键和值属性都为空,有人可以告诉我哪里错了吗?
在LoadProfile()
k 和 v 中为空。
网页配置
<profile enabled="true" inherits="SiteBuilder.Models.KeyValue">
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>