Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebViewPage _Layout.cshtml Injections are Null #38

Closed
squadwuschel opened this issue Aug 14, 2014 · 1 comment
Closed

WebViewPage _Layout.cshtml Injections are Null #38

squadwuschel opened this issue Aug 14, 2014 · 1 comment

Comments

@squadwuschel
Copy link

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>&nbsp;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
Copy link
Author

a workaround is to Move the "PermissionManager" Calls into an Html.Partial - here the PermissionManager is not Null and gets Injected.

@Html.Partial("_MainMenue")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant