<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%
if (Request.IsAuthenticated) {
%>
Welcome <b><%= Html.Encode(Page.User.Identity.Name) %></b>!
[ <%= Html.ActionLink("Log Off", "LogOff", "Account") %> ]
<br />
<% if(User.IsInRole("Administrator")) { %>
<br />
<%= Html.ActionLink("Home", "Index", "Home") %> | <%= Html.ActionLink("About", "About", "Home") %> | <%= Html.ActionLink("UserControl","UserControl","Account")%>
<% } else { %>
<br />
<%= Html.ActionLink("Home", "Index", "Home") %> | <%= Html.ActionLink("About", "About", "Home") %>
<%} %>
我想检查用户的角色,如果它是管理员,只有这样用户才能看到指向用户控件的链接
“'Data.User'不包含'IsInRole'的定义”