我需要在MVC中实现成员资格表格身份验证。我也使用Profile Group手动创建了ProfileCommon。现在我在创建用户时遇到此错误:
错误:尚未定义配置文件组“ProfileGroupPersonal”。
这是我的ProfileCommon.cs代码
public class ProfileGroupPersonal : System.Web.Profile.ProfileGroupBase
{
public virtual string UserName
{
get
{
return ((string)(this.GetPropertyValue("UserName")));
}
set
{
this.SetPropertyValue("UserName", value);
}
}
}
public class ProfileCommon : System.Web.Profile.ProfileBase
{
public virtual ProfileGroupPersonal Personal
{
get
{
return ((ProfileGroupPersonal)(this.GetProfileGroup("Personal")));
}
}
public virtual ProfileCommon GetProfile(string username)
{
return Create(username) as ProfileCommon;
}
}
ProfileCommon p = new ProfileCommon();
ProfileCommon profile = p.GetProfile(userName);
profile.Personal.UserName = userName;
我的web.config代码:
<profile inherits="FormAuthentication.Models.ProfileCommon" >
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="Test"/>
</providers>
</profile>