我有一个带有表单身份验证(用户名和密码)的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
}