WebViewPage _Layout.cshtml Injections are Null
squadwuschel opened this issue · 1 comments
squadwuschel commented
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" I think/hope its a bug or do you habe an alternate solution?
squadwuschel commented
a workaround is to Move the "PermissionManager" Calls into an Html.Partial - here the PermissionManager is not Null and gets Injected.
@Html.Partial("_MainMenue")