views:

358

answers:

0

I'm trying to add custom data to a standard ASP.Net forms authentication ticket as shown in the code sample here.

My call to FormsAuthentication.Encrypt always returns null. I've seen people say that it returns null when the userData param to the FormsAuthenticationTicket constructor is null, but my authTicket object looks fine.

I'm just hoping to find a clue as to why it's null.

            var authTicket = new FormsAuthenticationTicket( 1,
                                                            loggedinuser.UserName,
                                                            DateTime.Now,
                                                            DateTime.Now.AddMinutes( 10 ),
                                                            Login1.RememberMeSet,
                                                            stringwriter.ToString() );

            string encryptedTicket = FormsAuthentication.Encrypt( authTicket );  // null