Monday, March 2, 2015

FormsAuthentication.SetAuthCookie() not working

 

Quick Tip:

I have configured the membership provider to work with ASP.NET application which is going to deploy in to the SharePoint.

But when I used FormsAuthentication.SetAuthCookie() to set the Authentication Token it doesn’t work for me.

I have tried disabling anonymous authentication but still didn’t work.

Then I changed the FormsAuthentication.SetAuthCookie() method to following set of lines and ultimately worked.

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(txtUserName.Value, false, 60);
string encTicket = FormsAuthentication.Encrypt(ticket);
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

Post a Comment