How do I add first user (root) in ASP.NET MVC app?
问题 I'm using ASP.NET MVC Framwork and trying to grok the ASP Membership 3.5 stuff. What is the best way to add the first administrator user without having to log in? I've been staring at the membership starter kit's source without finding it. 回答1: A simple solution (especially or rather only for dev. purposes) by doing it in a "setup" action: if (!Roles.RoleExists("Administrator")) { Roles.CreateRole("Administrator"); } if (Membership.GetUser("Admin") == null) { Membership.CreateUser("Admin",