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 DuranoRank #238 · 10.3K reputationPosted Apr 25, 2015, 10:22 PM EDT
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 BageriRank #115 · 19.6K reputationPosted Apr 25, 2015, 6:28 AM EDT
http://www.c-sharpcorner.com/UploadFile/4d9083/creating-custom-role-manager-with-dynamic-menus-in-Asp-Net/
Abhineet SrivastavaRank #1,890 · 783 reputationPosted Apr 26, 2015, 9:20 AM EDT
Saineshwar BageriRank #115 · 19.6K reputationPosted Apr 26, 2015, 9:41 PM EDT
Marks as Answer if i have solved you problem
Tharindu N Chathuranga46 reputationPosted Apr 26, 2015, 10:46 PM EDT
Saineshwar BageriRank #115 · 19.6K reputationPosted Apr 26, 2015, 11:02 PM EDT