我正在 build 自己的 "user profile"
模块所在的选项之一,用户可以更改他的默认dnn
个人资料图片。我在“在后面的代码中”执行此操作时遇到问题。我正在使用 c#
.
这是我到目前为止所拥有的:
UserInfo myDnnUser = this.UserInfo;
myDnnUser.Profile.InitialiseProfile(PortalId);
myDnnUser.Profile.SetProfileProperty("Photo", "new filename");
myDnnUser.Profile.SetProfileProperty("PhotoURL", "new url");
ProfileController.UpdateUserProfile(myDnnUser);
但它不起作用,当我查看 dnn 使用的"file"表时,它仍然是相同的(旧)文件名。
有任何想法吗?
最佳答案
涉及三个表:UserProfile
, ProfilePropertyDefinition
和 Files
.
UserProfile 存储 ProfilePropertyDefinitions 的 PropertyValues。
“照片”PropertyName 的预期 PropertyValue 是对 Files 表的 FileID 引用,而不是文件名。在设置 Photo 之前,您需要获取 FileID:
var objFiles = new FileController();
FileInfo objFile = objFiles.GetFile("filepath", PortalID);
myDnnUser.Profile.Photo = objFile.FileId;
ProfileController.UpdateUserProfile(myDnnUser);
PhotoURL 是一个只读属性,用于检索 UserProfile 的 Photo 属性的 url。
关于asp.net - 如何在后面的代码中更新 dotnetnuke 用户配置文件图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7767652/