2
<%@ 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") %>
<%} %>
我想檢查用戶的角色,如果它是管理員只有那麼用戶可以看到用戶control.when鏈接,當我嘗試運行此代碼它給我一個錯誤說 「'Data.User'不包含'IsInRole'的定義」ASP.Net MVC檢查用戶在aspnet中的角色