Community Server用户的注册过程分析
from http://www.kwkj.cn/forums/forums/thread/3881.aspx
下面是Community Server用户的注册过程,是从sql server的profiler跟踪来的,下文从数据库的角度分析一下用户的注册过程,我们的cs论坛已转换为标准的asp.net 2.0的membership,经过对比cs的用户管理表和标准的asp.net 2.0的用户管理表结构一模一样,从aspnet_Applications到aspnet_WebEvent_Events共11个表。分析的目的就是为了下一步整合系统,作出自的会员注册系统。
Cs注册的过程大概分为:
(存储过程见附1:中间不重要的部分或写日志的部分不分析)
1、注册到标准的用户表中
2、注册到cs自定的用户表中。
3、给该用户增加Everyone角色
4、给该用户增加Registered角色
5、将用户的时区、昵称……的结构和数据添加到aspnet_Profile表中,cs初始值只有时区的值默认是8(东八区),其余的值都为空。
下面的存储过程好像是修改用户表中的数据。先走主线。
我们的程序员测试了用标准的asp.net 2.0的用户注册控件这册用户,顺利注册,但没有注册到aspnet_Profile中,曾经一直为这个表发愁,不知用什么算法读取这个表中的数据。查了些资料,发现这也是微软标准的字段,原来还以为是cs自己加上的呢?
参考了
http://www.microsoft.com/china/msdn/library/langtool/vbnet/VisualBasic2005chapter6.mspx?mfr=true
文章中的下面一段终于明白了profile的来龙去脉,其实道理挺简单的。
如果要加时区
1、先在web.config文件中申明(详细的看上面提到的文章)
<properties>
<add name = "timezone" type = "System.Double" defaultValue="0" />
</properties>
2、在程序里写:
Profile. timezone = txtLastName.Text
Profile.Save()
3、在程序里读:
txtLastName.Text = Profile. timezone
附1:上文的节选
用户配置文件
ASP.NET 2.0 中的用户配置文件有时称为用户个性化或配置文件个性化,在 Web 站点的 web.config 文件中进行配置。可以在该配置文件中以声明性方式声明希望为每个用户存储的数据,然后在某个特殊的 Profile 对象中填充对应的属性。下面的 web.config 文件子集配置 Web 站点来存储每个用户的 FirstName和 LastName字符串值:
<?xml version="1.0”?>
<configuration>
<system.web>
<authentication mode="Forms”/>
<profile inherits="System.Web.Profile.HttpProfileBase, System.Web,
Version=2.0.3600.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a">
<properties>
<add name="FirstName”type="System.String”/>
<add name="LastName”type="System.String”/>
</properties>
</profile>
</system.web>
</configuration>
Visual Studio 2005 从 web.config 文件读取这些配置信息,并动态地创建从 HttpProfileBase 继承的专用类。该专用类包含 web.config 文件中定义的具有正确数据类型的所有属性。图 6-12 例举一个在 Intellisense 中可用的自定义配置文件属性。
图 6-12 在 Intellisense 中可用的强类型配置文件属性。
在运行时,ASP.NET 2.0 负责管理配置文件数据的持久性。作为程序员,您唯一的任务是读写这些数据。下面的代码说明如何设置 FirstName和 LastName属性,并将它们保存在配置文件数据存储中:
Profile.FirstName = txtFirstName.Text
Profile.LastName = txtLastName.Text
Profile.Save()
要从 Profile 对象读回数据,只需颠倒赋值语句即可:
txtFirstName.Text = Profile.FirstName
txtLastName.Text = Profile.LastName
默认情况下,这些配置文件属性只能为经过身份验证的用户设置(因此也只为他们存储)。但在有些情况下,当用户匿名浏览站点时,您需要捕获信息;而当该用户登录站点时,您需要维护数据。ASP.NET 用户配置文件本身支持这种情况。必须使用 web.config 中的 <anonymousIdentification>元素显式启用匿名配置处理。然后,希望支持匿名用户的任何属性都必须将 allowAnonymous属性设置为 true。下面来自 web.config 的 XML 显示此应用程序的这些设置:
<anonymousIdentification enabled="true”/>
<profile inherits="System.Web.Profile.HttpProfileBase, System.Web,
Version=2.0.3600.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a”>
<properties>
<add name="FirstName”type="System.String”/>
<add name="LastName”type="System.String”/>
<add name="FirstVisit”type="System.String”allowAnonymous="true”/>
</properties>
</profile>
附2:存储过程分析
序号 |
存储过程 |
|
Exec dbo.aspnet_Membership_GetUserByName @ApplicationName=N'dev',@UserName=N'jgjgjg',@UpdateLastActivity=0,@CurrentTimeUtc=''2006-06-07 07:27:24:470'' |
|
|
1 |
declare @p12 uniqueidentifier set @p12='0A9D95BF-CA10-4F28-B88F-F0D658443CCB' exec dbo.aspnet_Membership_CreateUser @ApplicationName=N'dev',@UserName=N'jgjgjg',@Password=N'VZTGpRbu/3W+zY2AudYnv8ISrBA=',@PasswordSalt=N'ckq4OIs24bYpdwxrIbqX4g==',@Email=N'abcc@123.com',@PasswordQuestion=NULL,@PasswordAnswer=NULL,@IsApproved=1,@UniqueEmail=1,@PasswordFormat=1,@CurrentTimeUtc=''2006-06-07 07:27:24:000'',@UserId=@p12 output select @p12 |
|
|
|
exec dbo.aspnet_Profile_GetProperties @ApplicationName=N'dev',@UserName=N'jgjgjg',@CurrentTimeUtc=''2006-06-07 07:27:24:483'' |
|
|
|
|
2 |
declare @p2 int set @p2=2149 exec dbo.cs_user_CreateUpdateDelete @Action=0,@cs_UserID=@p2 output,@UserID='0A9D95BF-CA10-4F28-B88F-F0D658443CCB',@UserAccountStatus=1,@IsAnonymous=0,@IsIgnored=0,@ForceLogin=0,@AppUserToken='',@PropertyNames=default,@PropertyValues=default,@TimeZone=0,@PostRank=default,@PostSortOrder=0,@IsAvatarApproved=1,@ModerationLevel=0,@EnableThreadTracking=0,@EnableAvatar=0,@EnableDisplayInMemberList=1,@EnablePrivateMessages=0,@EnableOnlineStatus=0,@EnableEmail=1,@EnableHtmlEmail=1,@FavoritesShared=0,@SettingsID=1000 select @p2 |
|
|
|
exec dbo.cs_EventLog_Add @EventType=0,@EventID=401,@SettingsID=1000,@Message=N'jgjgjg was added from the role Everyone by jgjgjg',@Category=N'Role Update',@MachineName=N'KWKJ-FEFDN0OMQU' |
|
|
3 |
exec dbo.aspnet_UsersInRoles_AddUsersToRoles @ApplicationName=N'dev',@RoleNames=N'Everyone',@UserNames=N'jgjgjg',@CurrentTimeUtc=''2006-06-07 07:27:24:500'' |
|
|
|
exec dbo.cs_user_Get @UserName=N'jgjgjg',@UserID=0,@IsOnline=0,@LastAction=N'',@SettingsID=1000 |
|
|
|
exec dbo.cs_Roles_Get @UserID=2149,@SettingsID=1000 |
|
|
|
exec dbo.cs_EventLog_Add @EventType=0,@EventID=401,@SettingsID=1000,@Message=N'jgjgjg was added from the role Registered Users by jgjgjg',@Category=N'Role Update',@MachineName=N'KWKJ-FEFDN0OMQU' |
|
|
| |
4 |
exec dbo.aspnet_UsersInRoles_AddUsersToRoles @ApplicationName=N'dev',@RoleNames=N'Registered Users',@UserNames=N'jgjgjg',@CurrentTimeUtc=''2006-06-07 07:27:24:530'' |
|
|
|
exec dbo.cs_Roles_Get @UserID=2149,@SettingsID=1000 |
|
|
5 |
exec dbo.aspnet_Profile_SetProperties @ApplicationName=N'dev',@UserName=N'jgjgjg',@PropertyNames=N'publicEmail:S:0:0:yahooIM:S:0:0:timezone:S:0:1:commonName:S:1:0:signatureFormatted:S:1:0:signature:S:1:0:webLog:S:1:0:location:S:1:0:bio:S:1:0:webAddress:S:1:0:interests:S:1:0:icqIM:S:1:0:aolIM:S:1:0:occupation:S:1:0:msnIM:S:1:0:',@PropertyValuesString=N'8',@PropertyValuesBinary=0x,@IsUserAnonymous=0,@CurrentTimeUtc=''2006-06-07 07:27:24:923'' |
|
|
6 |
exec dbo.aspnet_Membership_UpdateUser @ApplicationName=N'dev',@UserName=N'jgjgjg',@Email=N'abcc@123.com',@Comment=NULL,@IsApproved=1,@LastLoginDate=''2006-06-07 07:27:24:000'',@LastActivityDate=''2006-06-07 07:27:24:000'',@UniqueEmail=1,@CurrentTimeUtc=''2006-06-07 07:27:24:937'' |
|
|
|
exec dbo.aspnet_Membership_GetUserByName @ApplicationName=N'dev',@UserName=N'jgjgjg',@UpdateLastActivity=0,@CurrentTimeUtc=''2006-06-07 07:27:24:937'' |
|
|
|
exec dbo.cs_user_CreateUpdateDelete @Action=1,@cs_UserID=2149,@UserID='0A9D95BF-CA10-4F28-B88F-F0D658443CCB',@UserAccountStatus=1,@IsAnonymous=0,@IsIgnored=0,@ForceLogin=0,@AppUserToken='',@PropertyNames=default,@PropertyValues=default,@TimeZone=8,@PostRank=default,@PostSortOrder=0,@IsAvatarApproved=1,@ModerationLevel=0,@EnableThreadTracking=0,@EnableAvatar=0,@EnableDisplayInMemberList=1,@EnablePrivateMessages=0,@EnableOnlineStatus=0,@EnableEmail=1,@EnableHtmlEmail=1,@FavoritesShared=0,@SettingsID=1000 |
只要努力就有收获,只有努力才能收获。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?