加载时显示为null的配置文件属性

时间:2012-04-26 12:02:50

标签: c# asp.net asp.net-mvc-3 asp.net-profiles

enter image description here
    KeyValue Files {get; set;}

public void SaveProfileData()
{         
    ProfileBase profile = HttpContext.Current.Profile;
    KeyValue kv = new KeyValue();
    kv = (KeyValue)profile.GetPropertyValue("Images");
    KeyValuePair<string, string> p = new KeyValuePair<string, string>(Guid.NewGuid().ToString(), File);
    kv.pair.Add(p);
    profile.SetPropertyValue("Images", (KeyValue) kv);
    profile.Save();
}


public void LoadProfile()
{
    ProfileBase profile = HttpContext.Current.Profile;
    Files = (KeyValue)profile.GetPropertyValue("Images");
}

[Serializable]
public class KeyValue
{
    public List<KeyValuePair<string,string>> pair = new List<KeyValuePair<string,string>>();
}

我将KeyValuePair存储在asp.net内置的配置文件中。当我的SaveProfile()函数运行时,它会保存所有对,当我调用loadprofile()时,它会加载所有对,但是所有对的密钥和&amp; value属性为null。问题是什么?

0 个答案:

没有答案