When ASP. NET Forms authentication method encounters Apple iOS

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.