0
我想擴展關鍵字的過濾器的授權屬性,而無需創建自定義授權對象。授權屬性擴展新的關鍵字
我知道構建關鍵字是角色,用戶。我想添加一個新的關鍵字調用級別,並查看用戶訪問級別是否大於特定級別。
這將允許我只爲用戶創建一個角色。
這樣做的用法是
[Authorize(level > 1)]
請讓我知道如果你需要更多的信息,讓您更好地瞭解我試圖解決這個問題。
我看了,但一直沒能解決這個問題。你能提供一個代碼示例嗎?這是我的。當我使用電平過濾器時出現錯誤。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
[Auth(Level > 1)]
public ActionResult Index()
{
}
public class Auth : AuthorizeAttribute
{
public int Level { get; set; }
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
}
}
我已經看了,並沒有能夠弄清楚如何讓我的自定義身份驗證工作中的新關鍵字。你能提供樣品嗎?這是我到目前爲止。 – Thuthinh 2013-02-19 15:14:10
@ user2085818我爲您提供了一個示例 – 2013-02-19 22:02:30