I am Using Ninject.MVC4 in my ASP.NET MVC4 Project and I am setting Up my Bindings in the created "NinjectWebCommon.cs" file.
I've overwritten the Default View, to Inject an Permissionmanager for my Views
public abstract class MvcBaseWebViewPage<TModel> : WebViewPage<TModel>
{
[Inject]
public IPermissionManager PermissionManager { get; set; }
}
and then I've set the new BaseView in the Views web.config
<!--<pages pageBaseType="System.Web.Mvc.WebViewPage">-->
<pages pageBaseType="Gui.Mvc.Views.MvcBaseWebViewPage">
now I've access to the PermissionManager in My Views like
@if (PermissionManager.HasRight(RightsQsMonitor.ConfigurationTrelloVisible))
{
<li>
<a href="#" target="_blank">
<i class="fa fa-trello fa-fw"></i> Trello</a></li>
}
that works great in all Views but for the "_Layout.cshmtl" its not working here is the "PermissionManager" Instance "Null" its getting Injected too late I think.