Custom Login control C# .net 4
I have everything set up to where I can call Membership.ValidateUser(user, pass)
I want to use Roles. Which is setup. I know that I can do Roles.CreateRole() and such.
The problem is. I need to be able to call User开发者_JS百科.IsInRole I don't know how to custom populate the user object by authentication. I Googled the crap outa this and was hoping someone could help. I want to build my own login stuff and not use the built in login control.
You can customize the look of login contol. Move control to the form, open the smart tag, click "Convert to template" link button. You can set up any layout and style but do not edit ids of inner controls (username, password etc)
UPDATE If you do not want to use build in login control, you can do all stuff manually. Below are some samples
//Use Membership.CreateUser to create new user
var newUser = Membership.CreateUser("username", "password");
//Here is the sample of adding new use to role
Roles.AddUserToRole("username", "role to add");
//Remove user from role
Roles.RemoveUserFromRole("username", "role to remove");
精彩评论