hey guys,
i wanna create a one login page which will automatically redirect to specific page based on user role.because there is no membership provider in .net 4.5. but i have created users and user roles.:) how is it possible with .net 4.5??
Loading
Vincent Maverick DuranoPosted Apr 26, 2015, 2:22 AM
You could then query your table and do the logic like this:
using (SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE")) {
string sql = "SELECT RoleID FROM UserRoles WHERE UserID= @UserID";
using (SqlCommand cmd = new SqlCommand(sql, connection)) {
connection.Open();
cmd.Parameters.AddWithValue("@UserID", "Pass the IDhere");
using(var adapter = new SqlDataAdapter(cmd)){
adapter.Fill(dt);
if (dt.Rows.Count > 0){
int roleID = Convert.ToInteger(dt.Rows[0][0].ToString());
if(roleID.Equals(1))
Response.Redirect("~/Admin.aspx");
else
Response.Redirect("~/User.aspx");
}
}
}
}
Saineshwar BageriPosted Apr 27, 2015, 3:02 AM
Tharindu N ChathurangaPosted Apr 27, 2015, 2:46 AM
Saineshwar BageriPosted Apr 27, 2015, 1:41 AM
Marks as Answer if i have solved you problem
Abhineet SrivastavaPosted Apr 26, 2015, 1:20 PM
Saineshwar BageriPosted Apr 25, 2015, 10:28 AM
http://www.c-sharpcorner.com/UploadFile/4d9083/creating-custom-role-manager-with-dynamic-menus-in-Asp-Net/