存储与会员数据aspnet_profile表中的其他数据 [英] Storing additional data in aspnet_profile table with Membership data

查看:135
本文介绍了存储与会员数据aspnet_profile表中的其他数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用API​​的成员在我的项目建在MVC2框架的OpenID的实现。
以外的用户名,我需要一些其它字段与在登记时用户相关联。

I am using Membership API with OpenId implementation in my project built on MVC2 framework. Other than the username , I need some other fields to be associated with the user at the time of registration.

我不知道,虽然,但我认为在asp.net档案系统是为这种类型的要求建造的​​。另外,我看到一个名为aspnet_profile其他成员表的表。

I am not sure though but I think Profile system in asp.net is built for this type of requirement. Also, I see a table with other membership tables named 'aspnet_profile'.

我添加应用程序的web.config以下设置启用配置文件:

I added following settings in the application web.config to enable the profile :

<profile enabled="true">
      <properties>
        <add  name="FullName" allowAnonymous="false"/>

      </properties>

    </profile>

正如前面所说,应用程序需要一些额外的数据与用户相关联,因此使用成员身份API创建用户时,我加code的几行制作进入个人资料表

As said before, application need some additional data to be associated with the user, so when creating a user using Membership API, I added few more lines of code for making entry into profile table

System.Web.Security.MembershipCreateStatus status = MembershipService.CreateUser(userModel.UserName, userModel.Password, userModel.UserName);

                   if (status == System.Web.Security.MembershipCreateStatus.Success)
                   {
                       FormsService.SignIn(userModel.UserName, true);
                       Session["Username"] = userModel.UserName;

                       dynamic profile = ProfileBase.Create(MembershipService.GetUser(userModel.UserName).UserName);
                       profile.FullName = userModel.UserFullName;
                       profile.Save();

                       RedirectToAction("Tech", "Home");



                   }

但我没有看到aspnet_profile表加入数据库中的所有行。另外,我想问这是否是一起默认成员资格数据

But I don't see any line added in the aspnet_profile table in the database. Also, I wanted to ask if this is the preferred way of adding additional data along with default membership data

推荐答案

我把它通过有关在web.config默认配置文件提供程序名称一些变化工作:

I made it work by making some changes related to default profile provider name in the web.config:

<profile enabled="true" defaultProvider="AspNetSqlProfileProvider">
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" applicationName="/" connectionStringName="ApplicationServices" type="System.Web.Profile.SqlProfileProvider" />
      </providers>

      <properties>
        <add  name="FullName" allowAnonymous="false"/>

      </properties>

    </profile>

我也加入呼吁ProfileBase.Create功能和设置Profile.FullName之间多了一个线;

Also I added one more line between call to ProfileBase.Create function and setting the Profile.FullName;

profile.Initialize(userModel.userName, true);

我终于看到了aspnet_profile表为新注册的用户的条目:)

I finally saw an entry in the aspnet_profile table for the newly registered user :)

这篇关于存储与会员数据aspnet_profile表中的其他数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆