2
我正在使用asp.net会员资料。我可以创建配置文件并检索值,但似乎无法设置属性值。 我使用下面的代码:asp.net会员资料更新
var profile = MemberProfile.GetUserProfile();
profile.fullName = tbFullName.Text;
profile.country = tbCountry.Text;
profile.city = tbCity.Text;
profile.streetAddress = tbStreeAddress.Text;
profile.phoneNumber = tbPhoneNumber.Text;
profile.Save();
,这是不更新个人资料。 我也在网上查找了几个解决方案,但似乎没有任何工作。 配置文件类看起来是这样的:
public class MemberProfile : ProfileBase
{
public static MemberProfile GetUserProfile(string username)
{
return (MemberProfile)Create(username);
}
public static MemberProfile GetUserProfile()
{
return (MemberProfile)Create(System.Web.Security.Membership.GetUser().UserName);
}
[SettingsAllowAnonymous(false)]
public string AuthGuid
{
get
{
var o = base.GetPropertyValue("auth_guid");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("auth_guid", value);
}
}
[SettingsAllowAnonymous(false)]
public string fullName
{
get
{
var o = base.GetPropertyValue("fullName");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("fullName", value);
}
}
[SettingsAllowAnonymous(false)]
public string country
{
get
{
var o = base.GetPropertyValue("country");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("country", value);
}
}
[SettingsAllowAnonymous(false)]
public string city
{
get
{
var o = base.GetPropertyValue("city");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("city", value);
}
}
[SettingsAllowAnonymous(false)]
public string streetAddress
{
get
{
var o = base.GetPropertyValue("streetAddress");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("streetAddress", value);
}
}
[SettingsAllowAnonymous(false)]
public string phoneNumber
{
get
{
var o = base.GetPropertyValue("phoneNumber");
if (o == DBNull.Value)
{
return string.Empty;
}
return (string)o;
}
set
{
base.SetPropertyValue("phoneNumber", value);
}
}
}
谢谢!