Search on the Internet a lot, according to the code above found that the normal sharing. Our site is the use of IIS7
After some time study. Realized,. The code is shared, first C # code
<summary>////After successful login, set cookies///</summary>//<param name= "entity" >< /param> public void Saveuserformscookie (Loginuser entity, bool Isrememberme = false) {var use Rdate = Serializationhelper.jsonserialize (entity); Serializes the object var cookietime = DateTime.Now; var cookieexpiration = cookietime.addminutes (FormsAuthentication.Timeout.TotalMinutes); if (isrememberme) {cookieexpiration = Cookietime.addyears (1); } var ticket = new FormsAuthenticationTicket (1, entity. Username, Cookietime, Cookieexpiration, False, userdate); var hash = Formsauthentication.encrypt (ticket); var cookie = new HttpCookie (Formsauthentication.formscookiename, hash) {Expires = Cookieexpirat Ion, Domain = formsauthentication.cookiedomain, Path = Formsauthentication.formscookiepath }; HTTPCONTEXT.CURRENT.RESPONSE.COOKIES.ADD (cookie); }
Then there is the Web configuration, which must be matched by a cryptographic algorithm. Our added Cokkiey have to do encryption. Then if you are. NET 4, and 4.5 encryption algorithms are not the same, must be unified, next is the Web. config configuration node <system.web> add
<compilation debug= "True" targetframework= "4.0"/>