I drag a asp.net login control on the page.And also create some roles during config tool: "website"-->"page configuration"(roles e.g. admin, user, developer).
What I did belows:
1. add a drop down list on the register.aspx, and binding to the aspnet_Roles table.
2. when I register a new user, I want to add one record in the table aspnet_UsersinRoles.
3. so i add the codes on the register.aspx.cs below:
using (ASPNETDBModel.ASPNETDBEntities accountEntities = new ASPNETDBModel.ASPNETDBEntities())
rolename = from role in accountEntities.aspnet_Roles
where role.RoleId == new Guid(ddList.SelectedValue)
FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false );
string continueUrl = RegisterUser.ContinueDestinationPageUrl;
The result is :
1. the user and role in inserted in the table aspnet_UsersinRoles.
The problem is :
1. The page is rendered wrongly, it is alwayse unlogon state event I input the use name and password.
2. the url contains some querystring "http://localhost:9633/HicCommunity/Account/Login.aspx?ReturnUrl=%2fHicCommunity%2fDefault.aspx
Any problem in codes? Please give your hands. Thanks