While using the asp:CreateUserWizard control to add forms based authentication users to my asp membership database I was encountering the following error:
Exception of type 'System.ArgumentException' was thrown.
Parameter name: encodedValue
The error above was being generated after I successfully created a new user. The issue it seems is with the control creating a cookie named: .ASPXAUTH
The solution expire the cookie.
private void ResetAuth()
{
HttpCookie aspCookie = new HttpCookie(".ASPXAUTH");
aspCookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(aspCookie);
}
{
HttpCookie aspCookie = new HttpCookie(".ASPXAUTH");
aspCookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(aspCookie);
}
This needs to be done on both the ContinueButtonClick and the onActiveStepChanged Event.
ActivateStepChanged
protected void ActiveStepChanged(object sender, EventArgs e)
{
ResetAuth();
}
{
ResetAuth();
}
ContinueButtonClick
protected void btnContinue_Clicked(object sender, EventArgs e)
{
ResetAuth();
}
{
ResetAuth();
}
A more detailed explanation of this and other asp.net login control issues can be found here within Bernado Nguyen-Hoan's Blog
No comments:
Post a Comment