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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:06:39+00:00 2026-06-12T23:06:39+00:00

I am using the Nuget MVC3 integration package for Autofac with MVC4. It mostly

  • 0

I am using the Nuget MVC3 integration package for Autofac with MVC4. It mostly works (constructor injection with Controllers is working great) but it does not inject registered services into action filter properties.

This is my registration in Global.asax.cs:

builder.RegisterType<AspNetMembershipProviderWrapper>().As(typeof(IUserService)).InstancePerHttpRequest();
// 5) action filters
builder.RegisterType<SetCultureAttribute>().As<IActionFilter>().PropertiesAutowired().SingleInstance();
builder.RegisterFilterProvider();
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

Then in the SetCultureAttribute I have this:

public IUserService _userService { get; set; } // it doesn't get injected, null

Nor does this work in the constructor of the attribute:

_userService = DependencyResolver.Current.GetService<AspNetMembershipProviderWrapper>(); // always returns null

DependencyResolver.Current.GetService() also returns null for all other registered services when called within the action filter’s constructor (I tried it out in the Debug windows to test it).

So I guess something is not working right. Is it ok to use MVC3 integration or should I use MVC4 Nuget package (which says it’s for RC)?

Is there anything else I could try to make this work?

  • 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-12T23:06:40+00:00Added an answer on June 12, 2026 at 11:06 pm

    In order to get ActionFilter injection working you need to register the provider, which I don’t see in your example:

    builder.RegisterFilterProvider();
    

    There is doc on that here:
    http://code.google.com/p/autofac/wiki/MvcIntegration3

    In either case, you registered the service as IUserService, so that’s how you’d have to resolve it.

    _userService = DependencyResolver.Current.GetService<IUserService>();
    

    You don’t need to register the attribute. Check the wiki link above for more.

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

Sidebar

Related Questions

My project is using AutoMapper, but I've used Nuget to install the package. However,
I added ASP.NET Web API RC to my MVC3 project using NuGet: Install-Package AspNetWebApi
I'm using the Ninject.MVC3 in my application and it has been working great until
I'm using SquishIt 0.8.7 from Nuget . But it doesn't seem to pick up
I'm using latest MVC4-RC (.net 4.0) with Microsoft ASP.NET Web Optimization Framework http://nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0-beta3 and
I'm currently using ninject.mvc3 in my asp.net webapi project, and it works fine. I
We are using Ninject in our MVC3 project to do dependency injection. I used
I've installed Migrator.NET using NuGet but when I attempt to run a migration using
not a showstopper but when using nuget in a project, it creates a packages.config
I just upgraded my MVC2 project to MVC3 and used the NuGet library package

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.