创建用户(CustomProfile)错误

时间:2013-04-25 18:52:07

标签: asp.net

我正在为一个Web项目做一个CustomProfile,到目前为止我一直在管理它。我使用了本指南:http://msdn.microsoft.com/en-us/magazine/cc163457.aspx并遵循它。我的项目是VB.NET,所以我按照C#文件的说明进行操作。我创建了一个自定义表,根据我的需要调整它,我面临两个问题。

    Sub SiteCreateUserWizard_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim UserProfile As ProfileCommon = Profile.GetProfile(SiteCreateUserWizard.UserName)
    UserProfile.FirstName = FirstNameTextBox.Text
    UserProfile.LastName = LastNameTextBox.Text
    UserProfile.Branch = branch.SelectedValue

    UserProfile.ProfileVersion = Microsoft.Samples.SqlTableProfileProvider.ProfileVersion
    UserProfile.Save()
End Sub

UserProfile.ProfileVersion行给了我一个错误。 “错误7'ProfileVersion'不是'ProfileCommon'的成员”和“错误8'ProfileVersion'不是'Microsoft.Samples.SqlTableProfileProvider'的成员。”

如果我评论这一行,它在某种程度上起作用。一旦我尝试注册用户,它就会给我以下错误:分析器错误消息:无法识别的配置属性:profileVersion。这是我的webconfig文件......

    <profile defaultProvider="MyCustomProfileProvider">
  <providers>
    <add name="MyCustomProfileProvider" type="Microsoft.Samples.SqlTableProfileProvider" connectionStringName="LocalSqlServer" table="CustomProfile" applicationName="/"  profileVersion="1" />



  </providers>

  <properties>
    <add name="FirstName" type="string" defaultValue="[null]" customProviderData="FirstName;nvarchar" />
    <add name="LastName" type="string" defaultValue="[null]" customProviderData="LastName;nvarchar" />
    <add name="MaternallastName" type="string" defaultValue="[null]" customProviderData="MaternalLastName;nvarchar" />
    <add name="Branch" type="string" defaultValue="[null]" customProviderData="Branch;nvarchar" />

  </properties>

如果我取出ProfileVersion它甚至不起作用。欢迎任何建议。半天,我被困在这一天,呵呵。

</profile>

1 个答案:

答案 0 :(得分:0)

如果你使用的是ASP.NET 4.5,那么新的方法就是SimpleMembershipProvider,它的更好,更容易,并支持开箱即用的OAuth,以启用“通过Facebook登录”类型登录! First read this article。至于提供个人资料方案checkout this post.

要查看的另一篇文章是here,并解释了访问其他基于用户/个人资料的信息的其他方式!