Why repeating login

A

ad

I use login controls in my web application, and have web.config as below:
<forms name="HealthCookie" loginUrl="Login.aspx" defaultUrl="Home.aspx"
protection="Validation" >
If the user enter wrong password in the login control, the failureText of
login control will appear.

When I deploy my web application to another machine, and the use enter the
correct password(the failureText does not appear), it login successful(the
failureText did not appear), but it did not deirect to Home.aspx, the
Login.aspx appear again.

What is wrong ? why repeating login?
below is my web.config and custum MembershipProvider
Please help me.






----------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
</appSettings>
<connectionStrings>
......................
</connectionStrings>
<system.web>
<httpRuntime maxRequestLength="2097151"/>
<membership defaultProvider="MyMembershipProvider">
<providers>
<add name="MyMembershipProvider" type="MyMembershipProvider"
minRequiredPasswordLength="7"/>
</providers>
</membership>
<httpHandlers>
....
</httpHandlers>
<siteMap>
<providers>
......
</providers>
</siteMap>
<authentication mode="Forms">
<forms name="HealthCookie" loginUrl="Login.aspx" defaultUrl="Home.aspx"
protection="Validation">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<customErrors mode="RemoteOnly"
defaultRedirect="~/ErrorPage/GenericErrorPage.aspx">
.......
</customErrors>
<pages maintainScrollPositionOnPostBack="true"
masterPageFile="~/MasterPage.master"/>
<sessionState mode="InProc"/>
<compilation debug="true">
<buildProviders>
.......
</buildProviders>
<assemblies>
......
</system.web>
</configuration>


public class MyMembershipProvider : MembershipProvider
{
private FormsAuthenticationUserCollection _users = null;
private FormsAuthPasswordFormat _passwordFormat;
//private int _MinRequiredNonAlphanumericCharacters = 0;
private int _MinRequiredPasswordLength = 4;
//private int _MaxInvalidPasswordAttempts = 5;
//private int _PasswordAttemptWindow = 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
"(e-mail address removed)", // Email
String.Empty, // passwordQuestion
"Comment", // Comment
true, // isApproved
false, // isLockedOut
DateTime.Now, // creationDate
DateTime.Now, // lastLoginDate
DateTime.Now, // lastActivityDate
DateTime.Now, // lastPasswordChangedDate
new DateTime(1980, 1, 1) // lastLockoutDate
);
return user;

}


public override bool ChangePassword(string username, string
oldPassword, string newPassword)
{
.............................................
}


public override void Initialize(string name,
System.Collections.Specialized.NameValueCollection config)
{
base.Initialize(name, config);
_passwordFormat = getPasswordFormat();
string sMin=config["minRequiredPasswordLength"].ToString();
sMin = WillNs.Util.GetDefault(sMin, "4");
_MinRequiredPasswordLength = int.Parse(sMin);
}

public override bool ValidateUser(string username, string password)
{
bool Authenticated = false;
Authenticated = DMHealth.CheckPW(username, password);
if (Authenticated)
{
//HttpContext.Current.Session.Abandon();
new AuthenticationSuccessEvent(username, this).Raise();
return true;
}
else
{
new AuthenticationFailureEvent(username, this).Raise();
return false;
}
}

protected FormsAuthenticationUserCollection getUsers()
{
if (_users == null)
{
AuthenticationSection section = getAuthenticationSection();
FormsAuthenticationCredentials creds =
section.Forms.Credentials;
_users = section.Forms.Credentials.Users;
}

return _users;
}

protected AuthenticationSection getAuthenticationSection()
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
return
(AuthenticationSection)config.GetSection("system.web/authentication");
}

protected FormsAuthPasswordFormat getPasswordFormat()
{
return
getAuthenticationSection().Forms.Credentials.PasswordFormat;
}
protected MembershipSection getMembershipSection()
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
return
(MembershipSection)config.GetSection("system.web/Membership");
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top