如何用profile拓展membership的信息 mvc
内置的aspnet_membership数据库表里面的字段是信息,一般满足不用了用户的需求,如果想更好的使用membership类,那就需要通过profile对membership进行拓展。拓展的信息是存在aspnet_Profile数据表里面的。
Profile对象存储表(aspnet_Profile)
|
字段名 |
类型 |
属性 |
说明 |
|
UserId |
uniqueidentifier |
FK: aspnet_Users.UserId |
用户ID |
|
PropertyNames |
ntext |
属性名称 |
|
|
PropertyValuesString |
ntext |
字符串值 |
|
|
PropertyValuesBinary |
image |
二进制值 |
数据是这个样子的:
| propertynames |
| Identify:S:0:5:Address:S:5:4:Phone:S:9:5: |
|
|
| 10000中国达人10000 |
说明:Identify、Address 、Phone是自己在web.config配置文件中的<profile>...</profile>自己中自定义的属性字段,这些属性字段全部存储在propertynames字段里面,自定义属性所定义的值“10000中国达人10000”都存储在propertyvaluesstring字段里面,自定义字段的数据类型和属性值可以这么看:举第一个字段Identify来说明:第一个“:”后面的“S”就是代表数据类型string,第二个“:”后面的“0:5”就是代表在propertyvaluesstring里面的从0到5个字符位置的内容“10000”是第一个字段Identify的值,其他属性字段及属性值以此类推。
1 <profile defaultProvider="SqlProvider"> 2 <providers> 3 <clear /> 4 <add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="dmsConnectionString" 5 applicationName="/" /> 6 </providers> 7 8 <properties> 9 <add name ="Identify" type ="String" allowAnonymous="true"/> 10 <add name ="Phone" type ="String" allowAnonymous="true"/> 11 <add name ="Address" type ="String" allowAnonymous="true"/> 12 </properties> 13 </profile>
浙公网安备 33010602011771号