Thursday, June 13, 2013

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown. Parameter name: encodedValue at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)

When you are working with SharePoint FBA controls like 

<asp:ChangePassword
 <asp:PasswordRecovery

you will get below error.

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown.  Parameter name: encodedValue  
 at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)   
 at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(String encodedSuffix)   
 at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)   
 at Microsoft.SharePoint.SPWeb.InitializeSPRequest()   
 at Microsoft.SharePoint.WebControls.SPControl.EnsureSPWebRequest(SPWeb web)   
 at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)   
 at Microsoft.SharePoint.ApplicationRuntime.BaseApplication.Application_PreRequestHandlerExecute(Object sender, EventArgs e)   
 at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PreRequestExecuteAppHandler(Object oSender, EventArgs ea)   
 at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   
 at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

There are many reasons to get this error.
1)      Make sure all the properties or attributes are correct for the control.
2)      Sometimes if you are working with forgot password or change password you can see the error. Cookies might create a problem as we are not logged in to change password.
3)      Add this attribute in the control MembershipProvider="giveyourmembershipname"
.CS FILE
public partial class ChangePassword : UnsecuredLayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected override bool AllowAnonymousAccess
        {
            get
            {
                return true;
            }
        }



        protected void myPasswordChanged(object sender, EventArgs e)
        {
            if (Request.Cookies[".ASPXAUTH"] != null)
            {
                HttpCookie myCookie = new HttpCookie(".ASPXAUTH");
                myCookie.Expires = DateTime.Now.AddDays(-1d);
//myCookie.Path = ApplicationName();
                Response.Cookies.Add(myCookie);
                Response.Write("surya");
            }
        }

        //ContinueDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
    }

ASPX page
  <asp:ChangePassword ID="ChangePassword1" runat="server" MembershipProvider="RSCMemberProvider" OnChangedPassword="myPasswordChanged"
                 DisplayUserName="true" InstructionText="Enter your username and old password."
                 ContinueDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
                 CancelDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
                 >



1 comment:

Followers