[Form("MemberCF/Registration", ShowValidationSummary = true,MessageOnSubmit = "You are now registered! Please click on activation link sent to your email to activate your membership")]
public class Registration : FormBase
{
public const string MemberTypeAlias = "User-Member";
Contour Index was outside the bounds of the array.
Hi im using umbraco 6 with contour 3 and I am getting an Index out of range error. An cant access the website at all.
Stack trace
Comment author was deleted
Did you create any code first forms?
Yeah I suppose it will help here it is:
using System;
using System.Collections.Generic;
using System.Web;
using Umbraco.Forms.CodeFirst;
using umbraco.cms.businesslogic.member;
using umbraco.BusinessLogic;
using Umbraco.Forms.Core.Providers.FieldTypes;
using System.Web.Security;
namespace Contour.CodeFirstExample
{
public enum FormPages
{
Registration
}
public enum FormFieldsets
{
Details
}
[Form("MemberCF/Registration", ShowValidationSummary = true,MessageOnSubmit = "You are now registered! Please click on activation link sent to your email to activate your membership")]
public class Registration : FormBase
{
public const string MemberTypeAlias = "User-Member";
public const string MemberGroupName = "Sinawe";
[Field(FormPages.Registration, FormFieldsets.Details,
Mandatory = true)]
public string Name { get; set; }
[Field(FormPages.Registration, FormFieldsets.Details,
Mandatory = true)]
public string Surname { get; set; }
[Field(FormPages.Registration, FormFieldsets.Details,
Mandatory = true,
Regex = @"(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})")]
public string Email { get; set; }
[Field(FormPages.Registration, FormFieldsets.Details,
Type = typeof(Password),
Mandatory = true)]
public string Password { get; set; }
[Field(FormPages.Registration, FormFieldsets.Details,
Type = typeof(Password),
Mandatory = true)]
public string RepeatPassword { get; set; }
[Field(FormPages.Registration, FormFieldsets.Details,"Contact Number",
Mandatory = true)]
public string Contact_Number { get; set; }
[Field(FormPages.Registration, FormFieldsets.Details,
Mandatory = true)]
public string Division { get; set; }
[Field(FormPages.Registration, FormFieldsets.Details,
Mandatory = true)]
public string Manager { get; set; }
//[Field(FormPages.Registration, FormFieldsets.Details,
// Type = typeof(Umbraco.Forms.Core.Providers.FieldTypes.CheckBox))]
//public string Newsletter { get; set; }
public override IEnumerableValidate()
{
var e = new List();
//checks if email isn't in use
if (Member.GetMemberFromLoginName(Email) != null)
e.Add(new Exception("Email already in use"));
//makes sure the passwords are identical
if (Password != RepeatPassword)
e.Add(new Exception("Passwords must match"));
return e;
}
public override void Submit()
{
//get a membertype by its alias
var mt = MemberType.GetByAlias(MemberTypeAlias); //needs to be an existing membertype
//get the user(0)
var user = new User(0);
//create a new member with Member.MakeNew
var member = Member.MakeNew(Name + Surname +"(" + Email +")" , mt, user);
//assign email, password and loginname
member.Email = Email;
member.Password = Password;
member.LoginName = Email;
//asign custom properties
member.getProperty("firstName").Value = Name;
member.getProperty("lastName").Value = Surname;
member.getProperty("contactNumber").Value = Contact_Number;
member.getProperty("division").Value = Division;
member.getProperty("manager").Value = Manager;
//asssign a group, get the group by name, and assign its Id
var group = MemberGroup.GetByName(MemberGroupName); //needs to be an existing MemberGroup
member.AddGroup(group.Id);
//generate the member xml with .XmlGenerate
member.XmlGenerate(new System.Xml.XmlDocument());
member.Save();
//add the member to the website cache to log the member in
//Member.AddMemberToCache(member);
//var myUser = System.Web.Security.Membership.GetUser();
//myUser.IsApproved = false;
}
}
}
Comment author was deleted
Ok think I might have found the issue, could you try updating the codefirst assembly to the one found here http://nightly.umbraco.org/Umbraco%20Contour/3.0.8%20WIP/ (the _update archive)
Please let me know if that fixes the issue, thanks :)
Shot!
Comment author was deleted
Great, thanks for confirming :)
is working on a reply...