Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
hi i am new to umbraco
ive recent made a login and signup page and use umbraco.cms.businesslogic.member.Member
login is working prefectly fine
but during registeration it gives error while checking for the previous existed users
here is the Register.aspx.cs code
{
if (string.IsNullOrWhiteSpace(tbEmail.Text) | string.IsNullOrWhiteSpace(tbPassword.Text) | string.IsNullOrWhiteSpace(tbUsername.Text))
litError.Text = string.Format(ErrorFormat, "Please complete all fields");
return;
}
// Check the user isn't already registered
if ((Member.GetMemberFromEmail(tbEmail.Text) == null) && (Member.GetMemberFromLoginName(tbUsername.Text) == null))
// Set the member type and group
var mt = MemberType.GetByAlias(MembersType);
var addToMemberGroup = MemberGroup.GetByName(MembersGroup);
//create the member, and set the password and email
var m = Member.MakeNew(tbUsername.Text, mt, new User(0));
m.Password = tbPassword.Text;
m.Email = tbEmail.Text;
// Add the member to the group
m.AddGroup(addToMemberGroup.Id);
//Save member
m.Save();
//Generate member Xml Cache
m.XmlGenerate(new System.Xml.XmlDocument());
// NOTE: This Is Optional
// Login the user
FormsAuthentication.SetAuthCookie(tbUsername.Text, false);
// Redirect to successful page (Usually their profile or member page)
Response.Redirect(library.NiceUrl(SuccessfulLoginPage));
else
// Error, member already exists with email or username used
litError.Text = string.Format(ErrorFormat, "User already exists");
it gives error on line that ive made BOLD
Good Morning Mohsin,
I guess your first if does not work correctly by using just one | instead of || for the logic or
Please try this line and tell me if it solve your problem:
if (string.IsNullOrWhiteSpace(tbEmail.Text) || string.IsNullOrWhiteSpace(tbPassword.Text) || string.IsNullOrWhiteSpace(tbUsername.Text))
Thanks, Theresa
but the problem lies between the lines ive mentioned
see these images
http://postimg.org/image/4xwtv7505/
http://postimg.org/image/pjg70ubyt/
problem solved by changing type of defaultMemberTypeAlias to that i ve created in umbraco members panel
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Object reference not set to an instance of an object during members registeration
hi i am new to umbraco
ive recent made a login and signup page and use umbraco.cms.businesslogic.member.Member
login is working prefectly fine
but during registeration it gives error while checking for the previous existed users
here is the Register.aspx.cs code
{
if (string.IsNullOrWhiteSpace(tbEmail.Text) | string.IsNullOrWhiteSpace(tbPassword.Text) | string.IsNullOrWhiteSpace(tbUsername.Text))
{
litError.Text = string.Format(ErrorFormat, "Please complete all fields");
return;
}
// Check the user isn't already registered
if ((Member.GetMemberFromEmail(tbEmail.Text) == null) && (Member.GetMemberFromLoginName(tbUsername.Text) == null))
{
// Set the member type and group
var mt = MemberType.GetByAlias(MembersType);
var addToMemberGroup = MemberGroup.GetByName(MembersGroup);
//create the member, and set the password and email
var m = Member.MakeNew(tbUsername.Text, mt, new User(0));
m.Password = tbPassword.Text;
m.Email = tbEmail.Text;
// Add the member to the group
m.AddGroup(addToMemberGroup.Id);
//Save member
m.Save();
//Generate member Xml Cache
m.XmlGenerate(new System.Xml.XmlDocument());
// NOTE: This Is Optional
// Login the user
FormsAuthentication.SetAuthCookie(tbUsername.Text, false);
// Redirect to successful page (Usually their profile or member page)
Response.Redirect(library.NiceUrl(SuccessfulLoginPage));
}
else
{
// Error, member already exists with email or username used
litError.Text = string.Format(ErrorFormat, "User already exists");
}
}
it gives error on line that ive made BOLD
Good Morning Mohsin,
I guess your first if does not work correctly by using just one | instead of || for the logic or
Please try this line and tell me if it solve your problem:
Thanks, Theresa
but the problem lies between the lines ive mentioned
see these images
http://postimg.org/image/4xwtv7505/
http://postimg.org/image/pjg70ubyt/
problem solved by changing type of defaultMemberTypeAlias to that i ve created in umbraco members panel
is working on a reply...