Wednesday, 1 June 2011

SharePoint - asp:ChangePassword control

While using the asp:ChangePassword control within a SharePoint application page I was getting the following exception.

Exception of type 'System.ArgumentException' was thrown.Parameter name: encodedValue

Using Fiddler I tracked this error down to the .ASPXAUTH cookie.   Setting this cookie back to null fixed this issue for me.

  1. Call code behind method onChangedPassword

 <asp:ChangePassword ID="cpUser"
MembershipProvider="MembershipProviderName"
OnChangedPassword="cpUser_PasswordChanged"
DisplayUserName="true" runat="server">
</asp:ChangePassword>




    2.  Clear .ASPXAUTH cookie




protected void cpUser_PasswordChanged(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);
}
}


No comments:

Post a Comment