我試圖隱藏我的主頁上的一些管理員特定的按鈕從沒有管理員的用戶。從我的主頁面調用我的HomeController中的方法
我的代碼看起來像這樣至今:
<% if (Request.IsAuthenticated)
{%>
<%: Html.ActionLink("Administrer", "Index", "User", new { Area = "Users" }, new { @class = "menubutton", @id = "settingsbutton" })%>
<%} else { }%>
現在我想要做的IF()語句檢查如果當前用戶是管理員。即時通訊使用ASP.NET會員系統,併爲每個用戶提供一個特定類別,並提供一些關於他是否是管理員(布爾)的信息。
我的問題是我如何去調用一個方法來檢查這個或類似的東西?
我在想這將是像if(Request.IsAuthenticated &&「檢查管理員的方法」) – AronChan 2012-04-11 18:36:35
我只是不知道如何從主頁面調用這種方法到控制器 – AronChan 2012-04-11 18:37:54
請參閱http:// stackoverflow。 com/questions/409213/how-can-i-create-a-view-that-has-different-displays-according-the-role-the-us或http://stackoverflow.com/questions/4610749/ asp-net-mvc-check-role-inside-view – 2012-04-11 18:48:22