The above code is throwing an exception on the first line (Member.GetMemberFromEmail([email protected]) )
I do know that Member.GetMemberFromEmail will return null if the email address doesn't exists. My problem is, the exception is being thrown from inside the GetmemberFromEmail method .
(When i commented that line and ran the program , the application threw the null reference exception from the next line MemberType memberType = MemberType.GetByAlias("AdminType"); )
Does anyone have any insight on the cause of this issue ?
I would appreciate any guidance to solve this problem.
The issue is caused by missing information (required by umbraco API) in the web.config file .
If you ever encounter the same problem , Please make sure to check for all the umbraco specific information in the web.config file before trying other options.
Member.GetMemberFromEmail threw a null reference exception
I am trying to create new members using the Umbraco API. Here is my code.
if (Member.GetMemberFromEmail("[email protected]") == null
)
{
MemberGroup mg = MemberGroup.GetByName("AdminGroup");
newMember.Email = "
[email protected]";
newMember.Password =
"Password";
newMember.LoginName =
[email protected];
newMember.getProperty(
"Address").Value = "Address";
//set value of property with alias address
newMember.getProperty(
"Phone").Value = "Phone";
//set value of property with alias city
//Generate member Xml Cache
//newMember.XmlGenerate(new System.Xml.XmlDocument());
newMember.AddGroup(mg.Id);
newMember.Save();
}
else
{
//member exists
}
The above code is throwing an exception on the first line (Member.GetMemberFromEmail([email protected]) )
I do know that Member.GetMemberFromEmail will return null if the email address doesn't exists. My problem is, the exception is being thrown from inside the GetmemberFromEmail method .
(When i commented that line and ran the program , the application threw the null reference exception from the next line MemberType memberType = MemberType.GetByAlias("AdminType"); )
Does anyone have any insight on the cause of this issue ?
I would appreciate any guidance to solve this problem.
Thanks
Figured it out guys.
The issue is caused by missing information (required by umbraco API) in the web.config file .
If you ever encounter the same problem , Please make sure to check for all the umbraco specific information in the web.config file before trying other options.
Thanks.
is working on a reply...