First, the problem arises
When I use the ASP. NET MVC4 to do development, use Forms authentication as authentication.
Usually in the Web. config add:
<authentication mode="Forms" > <forms loginurl="~/account/ Login" name=" Webcookie" slidingexpiration="True "timeout= "/> </authentication>
Then the user logs in successfully set up the cookies, the code is as follows:
Public Static voidSetticket (httpresponsebase response,BOOLRemeberme,intVersionstringIdentitystringdisplayName) {Formsauthentication.setauthcookie (identity, remeberme); stringUserData =DisplayName; varAuthTicket =NewFormsAuthenticationTicket (version, Identity, DateTime.Now, DATETIME.N ow. AddDays (Remeberme? -:1), Remeberme, UserData); stringEncrytedticket =Formsauthentication.encrypt (AuthTicket); HttpCookie Authcookie=NewHttpCookie (Formsauthentication.formscookiename, encrytedticket);Response. Cookies.add (Authcookie); }
I use formsauthenticationticket.version to store user role IDshere.
At first, I was complacent about the ingenuity and ingenuity of the design, and there was no problem running on the Android phone at all. But on iOS, no matter what the value of my version is set to, it always has a value of 2.
According to MSDN's explanation: If FormsAuthenticationTicket was created with a constructor that does not provide the version parameter, the version property returns 2; otherwise, version The FormsAuthenticationTicket property returns the value provided to the constructor for the.
Address: Http://technet.microsoft.com/zh-cn/magazine/system.web.security.formsauthenticationticket.version (vs.110). aspx
I've already created it using the constructor that provides the version parameter, but it's not working on iOS.
Find a lot of information did not get a good explanation, I hope the garden of the blog can help me explain this problem ah.
Later see the Microsoft page at the bottom: supported platforms:
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server R2, Windows 8, Windows Server, Windows 7, Window S Vista SP2, Windows Server 2008 (Server Core role not supported), Windows Server R2 (support for Server Core roles with SP1 or later; Itanium not supported)
I was relieved too.
Anyway, the problem that bothered me for a long time finally found the problem, I would like to use this article to warn the later.
What does this formsauthenticationticket.version attribute do, someone knows?