1. WINDOWS-based security verification web.config file: authorization> configuration> You can authenticate without any code in .aspx file, but You can import namespaces in the .aspx file to get the login user: system.security.principal if (user.Identity.isauthenticated) // Determines if the user is verified, it seems to have no {Windowsidentity ObjWinIdentity = Windowsidentity.getCurrent (); lblHelloMsg.Text = "the name:" objWinIdentity.Name "
Type:" objWinIdentity.AuthenticationType "IsInRole:" User.IsInRole ( "computername // groupname");} 2, web.config forms-based authentication Web.config file: credentials> forms> authentication>
authorization> system.Web> configuration> login.aspx file: Two text boxes need to be provided Fill in the user and password (TXTUSR, TXTPWD), a radio box judges whether or not a button control is required to respond to the code of Button as follows: Void DOLOGIN (Object sender, Eventargs E) {ix (Formsauthentication.authenticate (txtusr.value , txtpwd.value)) {FormSauthentication.RedirectFromLoginPage (txtusr.value, chkpersist.checked);} else // is set for code integrity, can not write {response.write ("Authentication Fails");}} then don't The page can get the value of the login user: if (user.Identity.isauthenticated) / / can not be required to judge {response.write ("Your name:" user.Identity.Name); response.write ("Verification Type:" User.Identity.authenticationType); // Forms, Windows, etc.} 3, based on custom Forms authentication web.config files (basically no settings): forms> authentication>
authorization> Custom-login.aspx file, the basic principle is the same as 2 in 2, such as if (blnisauthenticated) // Note this BLNISAUThenticated Is a variable defined / / when we entered the information of the user and the information of the database (or XML), exist, set the variable to true, and counter FALSE // This is a different place {FormSauthentication. RedirectFromLoginPage (txtusr.value, chkpersist.checked); // txtusr and chkpersist are TextBox, checkbox control} else {// verify failed prompt information} If other pages get user information, such as 2, exit landing Response to exit the login button: FormSauthentication.signout (); response.clear (); response.redirect (request.0referRER.tostring ()); // Redirect to the previous page