Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

User.IsInRole always return system.string[]

$
0
0

Hi,

I am creating menu hide / show using role based

In my .aspx

<% if (Context.User.IsInRole("Admin"))
                           {%><li><a id="admin" href="../../Admin/AdminLanding.aspx"><i class="fa fa-user-plus"></i>&nbsp;Admin</a><ul class="sub-menu"><li><a href="../../Admin/Register.aspx">New AppUser </a></li><li><a id="A3" href="#" runat="server">Role </a></li></ul></li><% } %>

In my Global.asax.cs

string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
 string UserRole = Master_Role.GetRoleById(int.Parse(roles)).RoleName;
                        //Let us set the Pricipal with our user specific details
                        e.User = new System.Security.Principal.GenericPrincipal(new System.Security.Principal.GenericIdentity(username, "Forms"), UserRole.Split(';'));

How to get role?


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>