+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Type 'Telerik.Sitefinity.Security.UserIdentity' is not marked as serializable.

Type 'Telerik.Sitefinity.Security.UserIdentity' is not marked as serializable.

2 posts, 0 answered
  1. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    24 Apr 2013
    Link to this post
    I'm receiving this error, "Type 'Telerik.Sitefinity.Security.UserIdentity' in assembly 'Telerik.Sitefinity, Version=5.3.3900.0, Culture=neutral, PublicKeyToken=b28c218413bdf563' is not marked as serializable.",  after logging in from a custom user control and redirect to a different page that looks at a session variable.

    Here is my stack trace:
    [SerializationException: Type 'Telerik.Sitefinity.Security.UserIdentity' in assembly 'Telerik.Sitefinity, Version=5.3.3900.0, Culture=neutral, PublicKeyToken=b28c218413bdf563' is not marked as serializable.]
    Microsoft.VisualStudio.WebHost.Connection.get_RemoteIP() +0
    Microsoft.VisualStudio.WebHost.Request.GetRemoteAddress() +65
    System.Web.HttpRequest.get_UserHostAddress() +21
    Telerik.Sitefinity.Security.Claims.SFClaimsAuthenticationManager.ValidateLimitations(ClaimsPrincipalProxy principal, HttpContext context) +114
    Telerik.Sitefinity.Security.Claims.SitefinityClaimsAuthenticationModule.OnPostAuthenticateRequest(Object sender, EventArgs e) +1247
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

     Here is my code for logging in the user:

                    string username = this.txtUsername.Text;
                    string password = this.txtPassword.Text;
                    bool rememberMe = this.cbRememberMe.Checked;

                    UserLoggingReason loginMessage = UserLoggingReason.Unknown;
                    var userManager = UserManager.GetManager("Default");
                    MediaSiteSessionHelper helper = new MediaSiteSessionHelper(Application, Session);

                    if (Membership.ValidateUser(username, password)) //check to make sure valid username/password
                    {

                        //Authenticate and log user in
                        string redirectUrl = string.Empty;
                        loginMessage = SecurityManager.AuthenticateUser(UserManager.GetDefaultProviderName(), username, password, rememberMe);

                        if (loginMessage == UserLoggingReason.Success)
                        {
                            var manager = UserManager.GetManager();
                            manager.Provider.SuppressSecurityChecks = true;
                            manager.SaveChanges();

                            FormsAuthentication.SetAuthCookie(username, true);

                            var user = userManager.GetUsers().Where(u => u.UserName == username).Single();
                            Guid userID = user.Id;

                            var getUserMode = from extended in context.user_extended_profile
                                              where extended.id == userID
                                              select new
                                              {
                                                  isTempPassword = extended.isTempPassword,
                                                  VerificationDate = extended.verification_date,
                                                  IsApproved = extended.is_approved,
                                                  ReviewDate = extended.approval_date
                                              };
                            try
                            {
                                //Determine where to send user
                                if (getUserMode.Single().isTempPassword)
                                {
                                    helper.RequirePasswordChange = true;
                                    helper.redirectURL = "/my-account?action=REQCHANGEPWD";
                                }
                                else if (!getUserMode.Single().VerificationDate.HasValue)
                                {
                                    helper.RequireAcctVerification = true;
                                    helper.RequireAcctApproval = true;
                                    helper.redirectURL = "/my-account/account-status";
                                }
                                else if (!getUserMode.Single().IsApproved)
                                {
                                    if (getUserMode.Single().ReviewDate.HasValue)
                                    {
                                        helper.AcctWasDenied = true;
                                    }
                                    else
                                    {
                                        helper.RequireAcctApproval = true;
                                    }
                                    helper.redirectURL = "/my-account/account-status";
                                }
                                else
                                {
                                    if (helper.redirectURL.IsNullOrEmpty())
                                    {
                                        redirectUrl = "/";
                                    }
                                    else
                                    {
                                        redirectUrl = helper.redirectURL;
                                        helper.redirectURL = null;
                                    }
                                }
                            }
                            catch (Exception err)
                            {

                                var userRoles = RoleManager.FindRolesForUser(user.Id);
                                if (userRoles != null)
                                {
                                    foreach (var role in userRoles)
                                    {
                                        if (role.Name == "Administrators")
                                        {
                                            redirectUrl = "/Sitefinity";
                                        }
                                    }
                                }
                                if (redirectUrl.IsNullOrEmpty())
                                {
                                    SecurityManager.Logout();
                                    Common.LogError("Login", err);
                                    this.responseText.InnerHtml = "Incorrect Username/Password Combination";
                                    this.responseText.Visible = true;
                                    return;
                                }
                            }
                            if (helper.redirectURL.IsNullOrEmpty())
                            {
                                Response.Redirect(redirectUrl);
                            }
                            else
                            {
                                Response.Redirect(helper.redirectURL);
                            }
                        }
                        else
                        {
                            this.responseText.InnerHtml = loginMessage.ToString(); // "Incorrect Username/Password Combination";
                            this.responseText.Visible = true;
                            return;
                        }
                    }
                    else
                    {
                        this.responseText.InnerHtml = "Incorrect Username/Password Combination";
                        this.responseText.Visible = true;
                        return;
                    }
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    06 Dec 2016
    29 Apr 2013
    Link to this post
    Hi,

    Possible causes for the problem are if you are using visual studio development server (Cassini) to authenticate, use IIS and the problem shouldn`t appear or or perform the authentication trough a proxy server.

    All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered