Originally, the company had a domain control server, and most users logged on to the computer through the domain. In this way, system users do not need to worry about verification. However, there are also a lot of personal computers, and there is no way to accept domain management, the system adopts form verification.
In fact, the reality is very simple, the principles are all known, but there are many problems in the actual use process. Therefore, we will post some of the problems involved in the Code to facilitate future queries.
Generate a ticket. If you must set expiration to generate a cookie, you can inherit the expiration in the ticket, but you must also add it. Otherwise, the cookie is not generated. It is unclear why.
Newusercookie. expires = newticket. expiration;
After the verification is successful, the URL redirection must be changed as follows: // This method is used
Response. Redirect (formsauthentication. getredirecturl (newticket. Name, newticket. ispersistent ));
// The following methods cannot be used
// Formsauthentication. redirectfromloginpage (newticket. Name, newticket. ispersistent );
Webconfig also needs the same encryption method, Cookie name, and so on. <Authentication mode = "forms">
<Forms name = ". aspxcookienames" Protection = "all" timeout = "60" loginurl = "login. aspx" defaulturl = "default. aspx"/>
</Authentication>
<Machinekey validationkey = "constraint" decryptionkey = "340a425lo09o1b4f7a72569p566fc281" validation = "sha1"/>
<Authorization>
<Deny users = "? "/>
<Allow users = "*"/>
</Authorization>