Method 1
String Username = Txtusername. Text. Trim ();
String PWD = Md5.md5 (txtpwd. Text. Trim ());
If (Users. validateuser (username, PWD ))
{
Formsauthentication. redirectfromloginpage (username, False );
If (Request [ " Returnurl " ] = Null | Request [ " Returnurl " ] = "" )
{
Response. Redirect ( " Admin/xxx. aspx " ); // Normal login page
}
Else
Response. Redirect (request [ " Returnurl " ]); // If other pages are redirected to the login page, the previous page is returned.
}
Else
// Webhelper. alertanrefresh ("incorrect account and password ");
Method 2
String Username = Txtusername. Text. Trim ();
String PWD = Md5.md5 (txtpwd. Text. Trim ());
If (Users. validateuser (username, PWD ))
{
Formsauthentication. setauthcookie (username, False );
String redirectionurl = Formsauthentication. getredirecturl (username, False );
If (Redireurl URL. tolower (). indexof ( " Cookies. aspx " ) > 0 )
{
Response. Redirect ( " Admin/xxx. aspx " ); // Normal login page
}
// Formsauthentication. redirectfromloginpage (username, false );
Response. Redirect (redireurl URL ); // If other pages are redirected to the login page, the previous page is returned.
}
String Username = Txtusername. Text. Trim ();
String PWD = Md5.md5 (txtpwd. Text. Trim ());
If (Users. validateuser (username, PWD ))
{
Formsauthentication. setauthcookie (username, False );
String redirectionurl = Formsauthentication. getredirecturl (username, False );
If (Redireurl URL. tolower (). indexof ( " Cookies. aspx " ) > 0 )
{
Response. Redirect ( " Admin/xxx. aspx " ); // Normal login page
}
// Formsauthentication. redirectfromloginpage (username, false );
Response. Redirect (redireurl URL ); // If other pages are redirected to the login page, the previous page is returned.
}
Author: ret00100 Source: Large Article The original text connection is clearly displayed on the page. Otherwise, the legal liability is retained.