我有一个带有表单身份验证(用户名和密码)的 Web 应用程序(.net 4.0)。我一直在尝试找出登录缓慢的问题,并得出结论,在初始登录时,页面需要 20-50 秒才能登录,并且每次后续登录(注销和重新登录)平均需要3秒。是什么导致首次登录需要这么长时间?大多数用户每天只会登录一次网站,所以这看起来网站很慢,而实际上它似乎只是初始登录。
<asp:Login ID="Login1"
CssClass="login"
runat="server"
InstructionText="Please enter your information."
CheckBoxStyle - CssClass="loginRememberMe"
RememberMeText="Remember Me"
width="300px"
Height="150px"
onloggingin="Login1_LoggingIn"
onauthenticate="Login1_Authenticate">
<TitleTextStyle CssClass="loginHeader" />
<TextBoxStyle CssClass="loginInput" />
<LoginButtonStyle CssClass="loginButton" />
<InstructionTextStyle Font - Italic="True" ForeColor="Black" / >
</asp:Login>
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
Login login = (Login)loginview1.FindControl("Login1");
MembershipProvider prov = Membership.Providers["AspNetSqlMembershipProvider"];
if (prov.ValidateUser(login.UserName, login.Password))
{
e.Authenticated = true;
AuthenticatedUser.ConnectionString = "PortalConnectionString";
AuditUserLogin(login.UserName, true);
}
else
{
AuditUserLogin(login.UserName, false);
e.Authenticated = false;
}
}
private void AuditUserLogin(string Username, bool Authenticated)
{
AuditLog.LogUserLoginAttempt(Username, Authenticated, getIP());
}
protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
{
//todo
}