I have this code inside the Page_Load of the Site.Master.cs.
if(User.IsInRole("Read"))
{
NavigationMenu.Visible = false;
}
and I get this error:
An object reference is required for the non-static field, method, or property 'Microsoft.VisualBasic.ApplicationServices.User.IsInRole(string).
Any clues?
You can get current HttpContext user and validate for given role using IsInRole method as below.
HttpContext.Current.User.IsInRole("Read")
Change your method as
if(HttpContext.User.IsInRole("Read"))
{
NavigationMenu.Visible = false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With