本文介绍了asp.net mvc-> Roles.IsUserInRole(用户名,角色)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们是否需要添加任何引用或导入任何名称空间用于Roles.IsUserInRole(username,role)->是否给出正确的结果?
Do we need to add any references or import any namespace for Roles.IsUserInRole(username,role) - > is it not giving the right result.
<% if(Model.Count < 1)
{%>
No User's Add Under You!
<% } else {
foreach (var item in Model) { %>
<tr class="tblheader">
<th> User Name </th>
<th> Last Activity </th>
<th> Administrator </th>
<th> Base User </th>
<th> Print User </th>
<th> SDI User </th>
<th> Edit User </th>
</tr>
<% if(Model.Count < 1)
{%>
No User's Add Under You!
<% } else {
foreach (var item in Model) { %>
<td class="usertd">
<%if(Roles.IsUserInRole(item.UserName,"Administrator")) { %>
<asp:Image runat="server" ImageUrl="~/Content/images/buttons/btn_rnd_save.png" alt="Yes" />
<% } else { %>
<asp:Image runat="server" ImageUrl="~/Content/images/buttons/btn_Close.gif" alt="No" />
<% } %>
</td>
<td class="usertd">
<%if(Roles.IsUserInRole(item.UserName,"BaseUser")) { %>
<asp:Image runat="server" ImageUrl="~/Content/images/buttons/btn_rnd_save.png" alt="Yes" />
<% } else { %>
<asp:Image runat="server" ImageUrl="~/Content/images/buttons/btn_Close.gif" alt="No" />
<% } %>
</td>
推荐答案
如果在
IsUserInRole
处设置断点,会命中吗?
, is it hit?
这篇关于asp.net mvc-> Roles.IsUserInRole(用户名,角色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!