Hope someone can help with this well known issue. It's so well reported on the forums but can't seem to find any solution that works. I have a custom membership and role provider that validate users from a normal custom sql table (not membership table).
A problem seems to occur after user has been validated and a cookie is being created. When i omit the cookie, i get no problem and everything works fine.
So i guess the question is how can you create a token for a generic user successfully without getting this error. The error i'm getting is:
Exception of type 'System.ArgumentException' was thrown.
Parameter name: encodedValue
This is my code:
SPSecurity.RunWithElevatedPrivileges(delegate(){
string usernamestring = GetTextBox("tbUsername").Text;
string passwordstring = GetTextBox("tbPassword").Text;
ATPAuthProvider.ATPMembershipProvider memProvider = new ATPAuthProvider.ATPMembershipProvider();
{
MembershipUser user = memProvider.GetUser(usernamestring, true);
if (user != null)
{
//All hell seems to break loose here...
FormsAuthentication.SetAuthCookie(user.UserName, false);
HttpContext.Current.Response.Redirect("/Pages/Home.aspx", false);
}
});
Any help is much appriciated