Dotnetnuke 如何在DNN中正确设置自定义配置文件属性?
我正在尝试将自定义属性保存到DNN 7中的现有用户配置文件,但未设置配置文件属性。我一定是理解错了什么 那么,如何在DNN中正确设置自定义配置文件属性Dotnetnuke 如何在DNN中正确设置自定义配置文件属性?,dotnetnuke,dotnetnuke-7,Dotnetnuke,Dotnetnuke 7,我正在尝试将自定义属性保存到DNN 7中的现有用户配置文件,但未设置配置文件属性。我一定是理解错了什么 那么,如何在DNN中正确设置自定义配置文件属性 UserInfo.Profile.SetProfileProperty("key","value") // I expect this to return "value", but it's always "" var value = UserInfo.Profile.GetProfileProperty("key"); // Even if
UserInfo.Profile.SetProfileProperty("key","value")
// I expect this to return "value", but it's always ""
var value = UserInfo.Profile.GetProfileProperty("key");
// Even if I save it...
ProfileController.UpdateUserProfile(UserInfo);
// It always returns ""
var savedValue = UserInfo.Profile.GetProfileProperty("key");
注意:我也尝试了InitialiseProfile,但这没有改变行为。下面是我如何从我为客户机提供的模块基类中的属性访问propertyvalue
public string SomeKey
{
get
{
var ppd = UserInfo.Profile.GetProperty("SomeKey");
if (ppd.PropertyValue == string.Empty)
{
var SomeKeyValue = "blah"
//update the user's profile property
UserInfo.Profile.SetProfileProperty("SomeKey", SomeKeyValue);
//save the user
DotNetNuke.Entities.Users.UserController.UpdateUser(PortalId, UserInfo);
//retrieve again
return SomeKey;
}
string returnValue = ppd.PropertyValue ??
(String.IsNullOrEmpty(ppd.DefaultValue) ? String.Empty : ppd.DefaultValue);
return returnValue;
}
}
谢谢我想我遗漏的部分是我没有通过UI为用户设置属性/类型。啊,是的,我想我也忘了提到那部分:D