Objective
Recently, there have been some problems in making forms authentication in ASP.
Problem
When a form is certified, the ticket is decrypted from the cookie value in the postauthenticaterequest event. As follows:
protected void application_postauthenticaterequest (Object sender, EventArgs e) { var authcookie = Request.cookies[formsauthentication.formscookiename]; if NULL ) { var authticket = formsauthentication.decrypt (authcookie.value); TODO ... }
There was no problem yesterday, but the following results were unexpectedly run again today:
This problem has never been met, only to resort to StackOverflow.
The final discovery requires the authentication method to be added to the configuration file:
<authentication mode="Forms"> </authentication>
Resolve the issue as set up above.
Summarize
The above encryption and decryption Formsauthentication.encrypt and Decrypt are also related to machine key , as the above unresolved can be resolved by setting machine key.
Reference URL:
FormsAuthentication Unable to validate data
Configure MachineKey
Form authentication (form authentication) issues