i have two different tables in my application named user one and user two.i want to stop user one users to see users two index page and vice versa.how may i apply this customrole.both index pages are protected with [Authorize(roles="one/two")].
when debugging moves to customprovider.cs one becomes null and other found that null refrence exception i could not handle.please help me.
here is my customprovider.cs code
- public override void AddUsersToRoles(string[] usernames, string[] roleNames)
- {
- throw new NotImplementedException();
- }
- public override string ApplicationName
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
- public override void CreateRole(string roleName)
- {
- throw new NotImplementedException();
- }
- public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
- {
- throw new NotImplementedException();
- }
- public override string[] FindUsersInRole(string roleName, string usernameToMatch)
- {
- throw new NotImplementedException();
- }
- public override string[] GetAllRoles()
- {
- throw new NotImplementedException();
- }
- public override string[] GetRolesForUser(string username)
- {
- DBEntities db = new DBEntities();
- string s = db.user1.Where(x => x.Email == username).FirstOrDefault().UserRole;
- string s1 = db.user2.Where(x => x.Email == username).FirstOrDefault().UserRole;
- if (s == null)
- {
- string[] res1 = { s1 };
- try
- {
- return res1;
- }
- catch (Exception e)
- {
- e.ToString();
- }
- return res1;
- }
- else
- {
- string[] res1 = { s };
- try
- {
- return res1;
- }
- catch (Exception e)
- {
- e.ToString();
- }
- return res1;
- }
- }
- public override string[] GetUsersInRole(string roleName)
- {
- throw new NotImplementedException();
- }
- public override bool IsUserInRole(string username, string roleName)
- {
- throw new NotImplementedException();
- }
- public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
- {
- throw new NotImplementedException();
- }
- public override bool RoleExists(string roleName)
- {
- throw new NotImplementedException();
- }