I have a c# mvc razor web application with custom membership and everything works wonderful.
I am able to get the logged in user name by using this: user.identity.name
.
I have a database of usernames and their roles.
Now the problem is, in one of my views I am trying to restrict access to only "admin"
so i tried using user.isinrole
however, this always returned false.
so then i tried using roles.isuserinrole
, then i get an exception that says its not enabled.
i Google around and found several custom controllers for role provider that has the function isuserinrole
.
my question is, do i need to create a custom contoller for isuserinrole
to be enabled?
in my view when i enter roles.
--> visual studio list a list of built in functions that has isuserinrole
, so my question is, will creating my own custom role provider override the built in functions?
assuming i have the custom function, how will my web application tie it all in and check if user is in role?
thanks in advance for your responses.