Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9159989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:37:43+00:00 2026-06-17T13:37:43+00:00

I have a small problem which, hopefully, you will help me put behind. I

  • 0

I have a small problem which, hopefully, you will help me put behind.

I am using a MvcSiteMapProvider, and I want to define visibility for each node using access to a DB via a service interface.

 public class AreaSiteMapNodeVisibilityProvider : MvcSiteMapProvider.Extensibility.ISiteMapNodeVisibilityProvider
{   
[Inject]
public ISecurityService _SecurityService {get;set;}
        public AreaSiteMapNodeVisibilityProvider()
    {
        
    }
    public bool IsVisible(SiteMapNode node, HttpContext context, IDictionary<string, object> sourceMetadata)
    {
        MvcSiteMapNode thisNode = node as MvcSiteMapNode;
        return _SecurityService.CalculateNodeVisibility(thisNode,context.Cache["someValueIHaveStoredHere"])
        
    }
}

However, my _SecurityService member is always null. Any suggestions? I accept any type of directions, including getting rid of my injection and going another way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:37:44+00:00Added an answer on June 17, 2026 at 1:37 pm

    Your ISecurityService is null, because in this case, Ninject is not managing the creation of MvcSiteMapProvider (in MVC app, Ninject resolves dependencies wired from controller root, because it manages the creation of controllers – it overrides the default method for creation controllers).

    Options to resolve your issue:

    1)
    Use Ninject as service locator. Not recommended!, as it is widely considered to be an anti-pattern (but it depends…).

    var app = HttpContext.ApplicationInstance as NinjectHttpApplication;
    var service = app.Kernel.Get<ISecurityService>();
    

    2) Read R. Gloor’s answer on similar question: MVC3, Ninject, MvcSiteMapProvider – How to inject dependency to overridden method and do it his way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem, which I think it will be easy for you
I have a small problem which i can't seem to figure out. I tried
I have a small problem which i can't seem to solve myself. Look at
i have a small problem here which i cannot fix,This post goes through but
Dear community members, I have a small problem, which involves a text input field
Problem: Have made a small mail program which works perfectly on my developer pc
have small problem, and would very much appreciate help :) I should convert byte
I have a small problem with the visibility of an ellipse. In runtime I
I have a small problem which I'm having a hard time troubleshooting. I just
I have a small problem here which I really am quite stuck in right

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.