惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - 阿昆

[分享]真正的分页存储过程,借鉴了CSDN上众多力量,除BUG版,分享给大家 CommunityServer页面间关系 CommunityServer研习心得 CommunityServer皮肤主题的更换 CommunityServer布局 - 阿昆 - 博客园 Community Server系列之七:快速找到需要修改的文件[技巧] Community Server系列之六:CS2中的关键词及数据结构 Community Server系列之八:CS2中的CSContext Community Server系列之四:Ajax在CS2.0中的应用1 Community Server配置对网址中的www信息处理功能分析 Community Server架构:博客业务详细分析 如何在 Microsoft Visual Studio 2005 中直接Debug Community Server 2.0 的代码 与 Visual Studio 2005 Web Application Projects Community Server2.0专注细节一 邮件提醒按钮实现(上) Community Server专题附录一: 什么是Threads & Processes Community Server专题九:MemberRole之Profile Community Server专题八:MemberRole之Membership深入篇 Community Server专题八:MemberRole之Membership Community Server专题七: Job & Timer Community Server专题六:Delegates & Events
CommunityServer实例分析
阿昆 · 2006-06-02 · via 博客园 - 阿昆
 

CommunityServer实例分析——注册新用户(1)

对于类似于CommunityServer(简称CS)这样如此庞大的系统,很多朋友苦于无法入手,根据我对CS研究的一点经验,感觉从具体实例入手是最简单直接的。因此,我首先以注册新用户这个实例来向大家一步步揭开CS的神秘面纱。

1. 准备工作

本文以CCSChina Community Server,基于CS二次开发)为例,下载地址: http://www.communityserver.cn/builds,在压缩包里面有完整的源码和安装说明。

1.1 安装CCS
按照安装说明安装好CCS(如果安装过程中有问题可以到http://www.communityserver.cn上提问),本文以CCS安装在http://localhost/ccs为例。

1.2 打开源码
压缩包解压后,在src目录下就是所有的源码,先确认已经将http://localhost/ccs这个虚拟目录指向了src\web目录(如果您使用的是其它虚拟目录,请事先用文本编辑器修改src\Community Server.slnsrc\web\CommunityServerWeb.csproj.webinfo其中的http://localhost/ccs为您的虚拟目录地址),不出意外,就可以用VS2003打开src\Community Server.sln了。

1.3. 页面效果
通过http://localhost/ccs/User/CreateUser.aspx可以访问注册页面,在注册页面,用户可以输入注册的基本信息,例如登录帐号、昵称、Email、密码等。在点击提交按钮后首先会对提交数据的合法性校验,例如:登录帐户是否为空、Email是否合法、两次输入密码是否一致等。数据合法性校验通过后,要检测是否已经存在相同的登录帐户、昵称和Email,最后就是将注册的数据提交到数据库,并提示用户已经注册成功。

3. 技术分析

3.1 分析页面源码
VS2003中,在CommunityServerWeb项目中,展开User目录,打开CreateUser.aspx文件,切换到HTML视图,代码如下:
<%@ Page SmartNavigation="False" Language="C#"  enableViewState = "false" %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<%@ Register TagPrefix="CSD" Namespace="CommunityServer.Discussions.Controls" Assembly="CommunityServer.Discussions" %>
<%@ Import Namespace="CommunityServer.Galleries.Components" %>
<%@ Import Namespace="CommunityServer.Blogs.Components" %>
<%@ Import Namespace="CommunityServer.Components" %>

<CS:ContentContainer runat="server" id="MPContainer" ThemeMasterFile = "ForumMaster.ascx" >
    <CS:Content id="BodyContentRegion" runat="server">
  <CS:CreateUser runat="server" />
 </CS:Content>
</CS:ContentContainer>

3.2 自定义控件
没有我们熟悉的文本输入控件等,只有几个自定义控件标记,如果有Asp.Net的自定义控件基础知识,那么应该可以想到,这里用的是自定义控件。顺便温习一下Asp.Net自定义控件,首先,对于CS:ContentContainer标签,根据标签中的CS前缀,我们在页首的申明上找到TagPrefix="CS"Register
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
根据其中的Namespace属性的值和Assembly属性的值我们可以知道,这里的CS:ContentContainer标签对应的源码就是在CommunityServer.Controls.dll中的CommunityServer.Controls.ContentContainer类。CommunityServer.Controls.dll实际上就是由解决方案中的CommunityServerControls项目生成的。

对于CS:ContentContainerCS:ContentCS中用的模版控件,其实在Asp.Net2.0中已经内置了这种模版控件。CS在这里是用的一个第三方的模版控件:MetaBuilders.WebControls.MasterPages.dll,限于篇幅,在这里我就不做详细介绍。还是看看我们今天的主角:
<CS:CreateUser runat="server" />
根据上面的知识,我们可以直接从CommunityServerControls项目中找到CommunityServer.Controls.CreateUser类(一个小技巧就是在VS2003中切换到类视图,可以很方便找到该类对应的.cs文件),位于User目录下的CreateUser.cs文件。

3.3 TemplatedWebControl
打开源码(public class CreateUser : SecureTemplatedWebControl),可以知道CreateUser继承自SecureTemplatedWebControl类,那我们先看看SecureTemplatedWebControl类,SecureTemplatedWebControl类很简单,就是检查一下是不是需要使用Https连接,SecureTemplatedWebControl类又是继承自TemplatedWebControl类。其实在CS中,大部分类似于注册页面这样的控件都是继承自TemplatedWebControl,我们先来分析一下TemplatedWebControl的作用。 

CommunityServer论坛首页在线人员显示过程
1
Web项目下的default.aspx文件调用自定义控件ForumGroupView (代码:default.aspx中的<Forums:ForumGroupView runat="server" />  )
2
、自定义控件ForumGroupView最终通过Skin \ASP.NET Forums\Web\Themes\default\Skins\View-ForumGroupView.ascx来进行UI层的数据显示;
3
、在View-ForumGroupView.ascx通过用户自定义控件<Forums:WhoIsOnline runat="server" />显示在线人员。
4
WhoIsOnline 的源码在:\ASP.NET Forums\Controls\WhoIsOnline.cs
5
、在4中的控件里,调用Components.Users.GetUsersOnline方法取得在线人员的数据
6
Components.Users.GetUsersOnline最终调用ForumsDataProvider中的抽象方法WhoIsOnline
7
SqlDataProviderWhoIsOnline方法最终调用SPforums_Users_Online来取得数据。

这是论坛在线人员的一个显示过程。其他的数据的显示基本也是这么个思路。