[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
в пользовательском профиле asp.net, и он также сохраняется, но когда я обращаюсь к нему, он показывает как свойство ключа, так и значение null, может ли кто-нибудь сказать мне, где я ошибаюсь?
В LoadProfile()
k и v равны нулю.
Web.config
<profile enabled="true" inherits="SiteBuilder.Models.KeyValue">
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>