How could get the User.Identity.Name on IOS (iphone) after FormsAuthentication.SetAuthCookie

I have a MVC 4 web app which will works on mobiles. Now it works OK on andriod system, but there is a problem on IOS system. After the user sign in, User.Identity.IsAuthenticated still false, WHY?

Then I have a test as follow:

if (Request.Cookies[".ASPXAUTH"] != null)   { 

       ViewBag.coName = Server.HtmlDecode(Request.Cookies[".ASPXAUTH"].Value);             }            

ViewBag.uName = User.Identity.Name;

ViewBag.status = System.Web.HttpContext.Current.Request.LogonUserIdentity.Name;            

ViewBag.ssName = System.Web.HttpContext.Current.Request.IsAuthenticated;            

ViewBag.isName = User.Identity.IsAuthenticated;

I found that the Request.Cookies[".ASPXAUTH"] had value, but User.Identity.IsAuthenticated is false.  But all this will be OK in andriod system.

Any body could kind help me to solve it?

Just for some clarification – this is a ASP.NET Web Application that happens to be running (within the browser) on these different platforms (e.g. Android, iOS etc.)?

If you are using Forms Authentication, which is built into most ASP.NET Applications, then it should handle all of this for you and the platform you are running on shouldn’t have much to do with it; it should just work (e.g. you shouldn’t need to be
decoding your Authentication Cookie at all
). Are you sure that you have Cookies enabled on these other platforms where you are experiencing these issues?

Could you post some code related to where you are actually performing your authentication?

Leave a Reply