gpt4 book ai didi

dotnetnuke - 如何在 DNN 中正确设置自定义配置文件属性?

转载 作者:行者123 更新时间:2023-12-01 16:19:27 26 4
gpt4 key购买 nike

我正在尝试将自定义属性保存到 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 I save it...
ProfileController.UpdateUserProfile(UserInfo);

// It always returns ""
var savedValue = UserInfo.Profile.GetProfileProperty("key");

注意:我也尝试了 InitialiseProfile,但这并没有改变行为。

最佳答案

下面是我如何从我为客户提供的模块基类中的属性访问属性值。

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;
}
}

关于dotnetnuke - 如何在 DNN 中正确设置自定义配置文件属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25512411/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com