0
我想創建一個攔截器並將其註冊到Simple Injector中。我創建了一個基於Simple Injector教程的攔截器(here)。在Simple Injector中創建和運行攔截器
攔截器將用於授權用戶,我需要讀取方法參數,然後檢查用戶是否有權執行該方法。
請注意,有一個授權屬性接收執行方法的名稱。
例子:
[Authorize("SaveProductsAuthorization")]
public void SaveProducts(filter, dataToSave)
{...}
這裏是攔截註冊
container.InterceptWith<MedTimeAuthorizeInterceptor>(
serviceType => serviceType == typeof(IInterceptionEnabler));
container.RegisterSingleton<AuthorizeInterceptor>();
在我ProfessionalController
有一個IInterceptionEnable
,像這樣:
public class ProfissionalController : ApiController, IInterceptionEnabler
我把一個破發點到攔截方法在授權攔截器中,沒有發生任何事情。
這裏有什麼問題?也許攔截登記是錯誤的?