I use the form based on the form of verification, this is also the most common, I only write a summary, the source code is too long, but it should not affect the code.
Web.config modification:
User login verification method,:
There are two input controls, one is user_tb, used to enter the user, one is psw_tb, used to enter a password
Private void Button1_Click (Object Sender, System.Eventargs E)
{
// User login verification
String ip = system.web.httpContext.current.Request.userHostAddress;
String user_name = user_tb.text;
String user_psw = psw_tb.text;
User_name = user_name.replace ("<", "<"). Replace (">", ">"). Replace ("", "") .Replace ("'", "'");
User_psw = user_psw.replace ("<", "<"). Replace (">", ">"). Replace ("," ") .Replace (" '","' ");
IF (user_name! = "" || user_psw! = "")
{
SqlConnection myconn = new sqlconnection ((string) configurationSettings.appsettings ["connString"]); // Connect Database
MyConn.open (); // Open
String validate_sql = "select * from web_user where user_name = '" user_name "' and user_psw = '" user_psw "";
SQLCommand Validate_Com = New Sqlcommand (Validate_SQL, MyConn);
SqlDataReader Validate = VALIDATE_COM.EXECUTEREADER ();
String temp = "";
While (Validate.Read ())
{
Session ["User_Name"] = user_name;
Session ["User_Flag"] = Validate ["user_flag"]. TOSTRING ();
Temp = "yes";
}
VALIDATE.CLOSE ();
IF (Temp == "YES")
{
User_tb.text = "";
PSW_TB.TEXT = ""
System.Web.Security.FormSauthentication.RedirectFromLoginPage (user_name, false);
Response.Redirect ("manage_index.aspx");
}
Else
{