ASP.NET 使用
ProfileBase 类创建用于用户配置文件的类。在启动启用了用户配置文件的应用程序时,ASP.NET 会创建一个类型为
ProfileCommon 的新类,该类从
ProfileBase 类继承。强类型访问器被添加到profile配置节中为每个属性定义的
ProfileCommon 类中。
ProfileCommon 类的强类型访问器调用
ProfileBase 基类的GetPropertyValue 和SetPropertyValue方法,分别用于配置文件属性值的检索和设置。
ProfileCommon 类的一个实例被设置为 ASP.NET 应用程序的Profile属性的值。
呵呵,上面的简介从MSDN拷贝过来的。现在进入正题,大家在使用Profile的时候是不是有些郁闷的地方?比方说不能在BLL类库工程中使用ProfileCommon,这样就不可避免的在页面层中写些ProfileCommon的操作,我觉得这样操作实在太麻烦了,在查找了相关资料的时候最后还是搞定了,可以完全在后台类库工程中使用ProfileCommon的方法,废话完毕(已经知道的就别看拉,呵呵)。
首先我自己创建了一个EclProfileCommon的类,此类继承于ProfileBase类,下面是此类的代码
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Profile;

namespace ecl.Common.Comm


{
public class EclProfileCommon : ProfileBase

{
[SettingsAllowAnonymous(true)]
[ProfileProvider("SqlProfileProvider")]
public string EnglishName

{

get
{ return base["EnglishName"].ToString(); }

set
{ base["EnglishName"] = value; }
}

[SettingsAllowAnonymous(true)]
[ProfileProvider("SqlProfileProvider")]
public string ChineseName

{

get
{ return base["ChineseName"].ToString(); }

set
{ base["ChineseName"] = value; }
}

[SettingsAllowAnonymous(true)]
[ProfileProvider("SqlProfileProvider")]
public string Telephone

{

get
{ return base["Telephone"].ToString(); }

set
{ base["Telephone"] = value; }
}

[SettingsAllowAnonymous(true)]
[ProfileProvider("SqlProfileProvider")]
public string CustomSex

{

get
{ return base["CustomSex"].ToString(); }

set
{ base["CustomSex"] = value; }
}

[SettingsAllowAnonymous(true)]
[ProfileProvider("SqlProfileProvider")]
public string Country

{

get
{ return base["Country"].ToString(); }

set
{ base["Country"] = value; }
}
}
}
第一步搞定:现在开始配置下web.config
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
<providers>
<remove name="AspNetSqlProvider" />
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresUniqueEmail="true"
requiresQuestionAndAnswer="true"
minRequiredPasswordLength="4"
minRequiredNonalphanumericCharacters="0"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="100"
applicationName="/" />
</providers>
</membership>
<profile enabled="true" defaultProvider="SqlProfileProvider" inherits="ecl.Common.Comm.EclProfileCommon">
<providers>
<clear/>
<add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="SqlServices" applicationName="/"/>
</providers>
<!--<properties>
<add name="EnglishName" type="string" />
<add name="ChineseName" type="string" />
<add name="CustomSex" type="string" />
<add name="Telephone" type="string" />
<add name="Country" type="string"/>
</properties>-->
</profile>
大家注意:<profile enabled="true" defaultProvider="SqlProfileProvider" inherits="ecl.Common.Comm.EclProfileCommon">
中的我配置了inherits="ecl.Common.Comm.EclProfileCommon"这句话的意思是让net生成的ProfileCommon类继承此类这个很关键哦,呵呵
接下来看我在BLL里的调用吧:

/**//// <summary>
/// 新增用户信息
/// </summary>
/// <param name="obj">用户实体</param>
public void AddMember(Account obj)

{
if (obj == null)
throw new NullReferenceException("参数不可以为 Null !");

MembershipCreateStatus status;

Membership.CreateUser(obj.NewUserName, obj.Password, obj.Email, obj.PasswordQuestion, obj.PasswordAnswer, obj.IsApproved, out status);

if (status != MembershipCreateStatus.Success)
throw new ApplicationException(status.ToString());

MembershipUser mu = Membership.GetUser(obj.NewUserName);

mu.Comment = obj.Comment;

Membership.UpdateUser(mu);

EclProfileCommon p = (EclProfileCommon)ProfileBase.Create(mu.UserName);
p.ChineseName = obj.ChineseName;
p.EnglishName = obj.EnglishName;
p.CustomSex = obj.Sex;
p.Telephone = obj.Telephone;
p.Save();
}
整个流程就这样了,我不太会表述。不明白的可以与我交流:zcyhappy@msn.com
达人表笑我!!!共享大家交流下,呵呵
欢迎来
www.msotec.com 交流学习
如果有WSS、MOSS的问题,欢迎到www.msotec.com 来讨论!!
本文以图示的方式,向读者展示Microsoft Windows Sharepoint Services V3.0的安装过程。
在以下图示的安装过程中,使用了下面所列出的软件:
Windows Server 2003 SP1
SQL Server 2005
.NET Framework 3.0
Microsoft Windows Sharepoint Services V3.0
1、安装必需的Windows组件
在“添加或删除软件”中,打开“添加/删除Windows组件”:
先把DNS设置成本机。


钩掉上图选中的复选框。然后选择“应用程序服务器”:

点击“详细信息”,安装ASP.NET、应用程序服务器控制台等组件:

选择“Internet信息服务”,点击“详细信息”,确认Internet信息服务管理器已经被选中,如果需要,可以安装SMTP服务:
选中“网络服务”组件:
点击“详细信息”,选择安装DNS服务:

点击确定,完成Windows组件的安装:

2、配置AD环境
在服务器的管理工具中打开“管理您的服务器”

点击“添加或删除角色”

选择要添加“域控制器”角色:

启动了AD安装向导:






安装过程中进行网络诊断时,有可能提示DNS未正确设置,选择“在这台计算机上安装并配置DNS服务器…”:
完成AD安装后,点击“立即重新启动”,重启服务器
3、安装.Net 3.0框架 WSS3.0需要使用Windows Workflow Foundation这个组件,所以我们需要在服务器上安装这个组件。现在Windows Workflow Foundation已经是.NET Framework 3.0的一个子组件了,所以我们要在服务器上直接安装.NET Framework 3.0(.NET Framework 3.0也包含了.NET Framework 2.0) 运行.NET Framework 3.0的安装程序:



4、安装SQL SERVER 2005











安装wss v3









到此处已安装完毕了,此文希望能给新手一点点帮助,也给自己加深印象。
如果有WSS、MOSS的问题,欢迎到www.msotec.com 来讨论!!谢谢