Thanks, below is my web.config and custum MembershipProvi der
Please help me.
<?xml version="1.0"?>
<configuratio n xmlns="http://schemas.microso ft.com/.NetConfigurati on/v2.0">
<appSettings>
</appSettings>
<connectionStri ngs>
............... .......
</connectionStrin gs>
<system.web>
<httpRuntime maxRequestLengt h="2097151"/>
<membership defaultProvider ="MyMembershipP rovider">
<providers>
<add name="MyMembers hipProvider" type="MyMembers hipProvider"
minRequiredPass wordLength="7"/>
</providers>
</membership>
<httpHandlers >
....
</httpHandlers>
<siteMap>
<providers>
......
</providers>
</siteMap>
<authenticati on mode="Forms">
<forms name="HealthCoo kie" loginUrl="Login .aspx" defaultUrl="~/Home.aspx"
protection="Val idation">
</forms>
</authentication>
<authorizatio n>
<deny users="?"/>
</authorization>
<customErrors mode="RemoteOnl y"
defaultRedirect ="~/ErrorPage/GenericErrorPag e.aspx">
.......
</customErrors>
<pages maintainScrollP ositionOnPostBa ck="true"
masterPageFile= "~/MasterPage.mast er"/>
<sessionState mode="InProc"/>
<compilation debug="true">
<buildProviders >
.......
</buildProviders>
<assemblies>
......
</system.web>
</configuration>
public class MyMembershipPro vider : MembershipProvi der
{
private FormsAuthentica tionUserCollect ion _users = null;
private FormsAuthPasswo rdFormat _passwordFormat ;
//private int _MinRequiredNon AlphanumericCha racters = 0;
private int _MinRequiredPas swordLength = 4;
//private int _MaxInvalidPass wordAttempts = 5;
//private int _PasswordAttemp tWindow = 5;
#region Not Implemented Members
public override string ApplicationName
{
............... ..............
public override MembershipUser GetUser(string username, bool
userIsOnline)
{
DateTime myDate = DateTime.Today;
MembershipUser user = new MembershipUser(
Name, // Provider name
username, // Username
null, // providerUserKey
"aa@wfs.tan.edu .tw", // Email
String.Empty, // passwordQuestio n
"Comment", // Comment
true, // isApproved
false, // isLockedOut
DateTime.Now, // creationDate
DateTime.Now, // lastLoginDate
DateTime.Now, // lastActivityDat e
DateTime.Now, // lastPasswordCha ngedDate
new DateTime(1980, 1, 1) // lastLockoutDate
);
return user;
}
public override bool ChangePassword( string username, string
oldPassword, string newPassword)
{
............... ............... ...............
}
public override void Initialize(stri ng name,
System.Collecti ons.Specialized .NameValueColle ction config)
{
base.Initialize (name, config);
_passwordFormat = getPasswordForm at();
string sMin=config["minRequiredPas swordLength"].ToString();
sMin = WillNs.Util.Get Default(sMin, "4");
_MinRequiredPas swordLength = int.Parse(sMin) ;
}
public override bool ValidateUser(st ring username, string password)
{
bool Authenticated = false;
Authenticated = DMHealth.CheckP W(username, password);
if (Authenticated)
{
//HttpContext.Cur rent.Session.Ab andon();
new AuthenticationS uccessEvent(use rname, this).Raise();
return true;
}
else
{
new AuthenticationF ailureEvent(use rname, this).Raise();
return false;
}
}
protected FormsAuthentica tionUserCollect ion getUsers()
{
if (_users == null)
{
AuthenticationS ection section = getAuthenticati onSection();
FormsAuthentica tionCredentials creds =
section.Forms.C redentials;
_users = section.Forms.C redentials.User s;
}
return _users;
}
protected AuthenticationS ection getAuthenticati onSection()
{
Configuration config =
WebConfiguratio nManager.OpenWe bConfiguration( "~");
return
(Authentication Section)config. GetSection("sys tem.web/authentication" );
}
protected FormsAuthPasswo rdFormat getPasswordForm at()
{
return
getAuthenticati onSection().For ms.Credentials. PasswordFormat;
}
protected MembershipSecti on getMembershipSe ction()
{
Configuration config =
WebConfiguratio nManager.OpenWe bConfiguration( "~");
return
(MembershipSect ion)config.GetS ection("system. web/Membership");
}
}
"Tim_Mac" <ti********@com munity.nospam级 糶秎ン穝籇:uP **************@ TK2MSFTNGP03.ph x.gbl...
hi ad,
how can we know what's wrong when you didn't post any code?!
please post your web.config and all the code-behind for your login page.
tim