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 7807695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:55:56+00:00 2026-06-02T02:55:56+00:00

I must be doing something wrong because I have replicated many answers on this

  • 0

I must be doing something wrong because I have replicated many answers on this subject. My attribute binding is not being hit and I’m not sure why.

Controller.cs

[NatGeoUserAccessAuthorization]
        [HttpGet]
        public virtual ActionResult Teacher(string id)
        {

Attribute/Fitler

public class NatGeoUserAccessAuthorizationAttribute : FilterAttribute{}
    public class NatGeoUserAccessAuthorizationFilter : IAuthorizationFilter 
    {
        private readonly IUsersService _usersService;

        public NatGeoUserAccessAuthorizationFilter(IUsersService usersService)
        {
            _usersService = usersService;
        }

        public string QueryStringName { get; set; }

        #region Implementation of IAuthorizationFilter

        public void OnAuthorization(AuthorizationContext filterContext)
        {
            if (!_usersService.HasUserAccess(filterContext.HttpContext.User.Identity.Name, filterContext.HttpContext.Request.QueryString[QueryStringName ?? "id"]))
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "AccessDenied" }, { "controller", "Error" } });
            }
        }

        #endregion
    }

Global.asax

protected void Application_Start()
        {            
            // NLog Custom Layouts
            ConfigurationItemFactory.Default.LayoutRenderers.RegisterDefinition("utc_date", typeof(UtcDateRenderer));
            ConfigurationItemFactory.Default.LayoutRenderers.RegisterDefinition("web_variables", typeof(WebVariablesRenderer));

            // Setup IoC Container
            DependencyResolver.SetResolver(Bootstrap.Configure((kernel) =>
            {
                kernel.Bind<IDatabaseFactory>().To<DatabaseFactory<MySqlConnection>>().InRequestScope().WithConstructorArgument("connectionString", Config.Data.MySQLConnection);

                ManagerBindings.Register(kernel);
                ProviderBindings.Register(kernel);
                RepositoryBindings.Register(kernel);
                ServiceBindings.Register(kernel);
                ValidationBindings.Register(kernel);

                kernel.BindFilter<NatGeoUserAccessAuthorizationFilter>(FilterScope.Action, 0).WhenActionMethodHas<NatGeoUserAccessAuthorizationAttribute>();

                kernel.Bind<IUserProfile>().To<UserProfile>();
                kernel.Inject(Roles.Provider);
            }));

            // Custom Default Model Binder
            ModelBinders.Binders.DefaultBinder = new ValidationModelBinder();

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }

Bootstrap.cs

public class Bootstrap
    {
        public delegate void IocRegistrationDelegate(IKernel kernel);

        public static IDependencyResolver Configure(IocRegistrationDelegate serviceBindings)
        {
            var kernel = new StandardKernel();

            serviceBindings.Invoke(kernel);

            return new NinjectDependencyResolver(kernel);
        }
    }
  • 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-02T02:55:58+00:00Added an answer on June 2, 2026 at 2:55 am

    You are using an own bootstrapping mechanism that doesn’t support filter bindings. Read the docu how to use the one that comes with Ninject.Mvc3 on http://github.com/ninject/ninject.web.mvc/wiki

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

Sidebar

Related Questions

I must be doing something wrong here (because really, what are the chances of
I must be doing something wrong... Or this may be a bug in YAJL,
I'm facing a apparently very strange problem (I must be doing something wrong, just
I have found out that I am doing WPF wrong and frustratingly must overhaul
Ok, I know I must be doing something wrong, but darned if I can
I must be doing something wrong, but my code is very basic, hardly even
I think I must be doing something stupid. Unfortunately, due to the nature of
So as I am architecting my project, I'm thinking I must be doing something
Okay, I know I'm doing something wrong - but can't figure out a better
I might be doing something completely wrong here but for some reason the values

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.