troygoode / MembershipStarterKit

The starter kit provides the Asp.Net MVC controllers, models, and views needed to administer users & roles.
http://github.com/TroyGoode/MembershipStarterKit
MIT License
198 stars 66 forks source link

Creating new user without roles in UserAdministration #26

Closed Armar closed 12 years ago

Armar commented 12 years ago

If there is no roles at all, unhandled System.NullReferenceException is thrown when trying to create a new user MvcMembership\Views\UserAdministration\CreateUser.cshtml:line 21

    <fieldset>
        <h3 class="mvcMembership">Initial Roles</h3>
        @for(var i = 0; i < Model.InitialRoles.Count; i++){ 
            var role = Model.InitialRoles.ElementAt(i);
            <div>
                <input name="InitialRoles[@i].Key" type="hidden" value="@role.Key" />
                <label>@Html.CheckBox("InitialRoles[" + i + "].Value", role.Value) @role.Key</label>
            </div>
        }
    </fieldset>
troygoode commented 12 years ago

I was unable to reproduce, but ea667a517ee7f8b8f0550678877583d724ddbad2 may fix your problem. Try upgrading to package version 3.7.