正如标题中所说,我使用的登录控件与我第一次登录时的重定向方式不同。问题是我第一次登录重定向是正确的(default.aspx),在我注销然后再次登录后,它会将我带到我注销的页面。我不知道该怎么做!感谢所有帮助!谢谢!
<asp:Login ID="Login1" runat="server" DestinationPageUrl="~/Default.aspx" DisplayRememberMe="False"
TitleText="" UserNameLabelText="Username:" OnAuthenticate="Login1Authenticate"
FailureText="Incorrect username or password" Width="100%" VisibleWhenLoggedIn="False"
FailureAction="Refresh" >
</asp:Login>
protected void Login1Authenticate(object sender, AuthenticateEventArgs e)
{
var filecontent = Server.MapPath(@"~/App_Data/UsersFile.txt");
var lines = File.ReadAllLines(filecontent);
foreach (var line in lines)
{
if (line.Contains(@"username"))
{
var str = line; int index = str.IndexOf("=", StringComparison.Ordinal);
var newstr = str.Substring(index + 1);
Username = newstr.Trim();
}
if (line.Contains(@"password"))
{
var str = line; int index = str.IndexOf("=", StringComparison.Ordinal);
var newstr = str.Substring(index + 1);
Password = newstr.Trim();
}
if ((!Login1.UserName.Trim().Equals(Username)) || (!Login1.Password.Trim().Equals(Password))) continue;
e.Authenticated = true;
LogUserActions(Username, "Logged in successfully at: ");
break;
}
if (e.Authenticated) return;
LogUserActions(Username, "Failed to login in at: ");
LoginStatus1_ModalPopupExtender.Show();
}