Form验证的过程如下:
其代码大致如下:
FormsAuthenticationTicket Tickect=new FormsAuthenticationTicket(1,UserId,DateTime.Now,DateTime.Now.AddMinutes(60),false,EncryptedPassWord);
string encryptedTickectStr=FormsAuthentication.Encrypt(Tickect);
HttpCookie authcookie=new HttpCookie(FormsAuthentication.FormsCookieName,encryptedTickectStr);
Response.Cookies.Add(authcookie);
string encryptedTickectStr=FormsAuthentication.Encrypt(Tickect);
HttpCookie authcookie=new HttpCookie(FormsAuthentication.FormsCookieName,encryptedTickectStr);
Response.Cookies.Add(authcookie);
<configuration>
<system.web>
<authentication>
<forms name=".ASPXAUTH"
loginUrl="logon.aspx"
protection="all" <!-- Protection must be identical.-->
timeout="30"
path="/" > <!-- Path must have a compatible scope.-->
</authentication>
<!-- Validation and decryption keys must exactly match and cannot
be set to "AutoGenerate". The validation algorithm must also
be the same. -->
<machineKey>
validationKey= "C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
decryptionKey= "8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
validation="SHA1"
isolateApplications="false"
</machineKey>
</system.web>
</configuration>
<system.web>
<authentication>
<forms name=".ASPXAUTH"
loginUrl="logon.aspx"
protection="all" <!-- Protection must be identical.-->
timeout="30"
path="/" > <!-- Path must have a compatible scope.-->
</authentication>
<!-- Validation and decryption keys must exactly match and cannot
be set to "AutoGenerate". The validation algorithm must also
be the same. -->
<machineKey>
validationKey= "C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
decryptionKey= "8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
validation="SHA1"
isolateApplications="false"
</machineKey>
</system.web>
</configuration>