0

我正在为一个 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>
4

1 回答 1

0

如果您使用的是 ASP.NET 4.5,新方法是 SimpleMembershipProvider,它更好、更容易,并且支持开箱即用的 OAuth 以启用“通过 Facebook 登录”类型的登录!首先阅读这篇文章。至于提供配置文件方案,请查看此帖子。

另一个要查看的帖子在这里,并解释了访问其他基于用户/个人资料的信息的其他方法!

于 2013-04-25T21:20:09.060 回答