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

The Archive Base Latest Questions

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

Back in MVC3, I had a custom ControllerFactory which would use my own container

  • 0

Back in MVC3, I had a custom ControllerFactory which would use my own container (as abstracted by my business logic) to instantiate controllers and pass them services they needed.

I’m trying to implement something similar in MVC4 using the new ApiController.

I’ve got a static/shared method Core.DependencyResolverFactory.Resolver which returns an IDependencyResolver. This in turn has a number of Resolve(...) and ResolveAll(...) methods and overloads.

So… How can I implement the same thing in MVC4?

I’ve tried setting up my own ServiceLocator but can’t find the interface Microsoft.Practices.ServiceLocation.IServiceLocator in any of the framework assemblies.

I’m not too worried about being tied to an underlying container as it’s already being abstracted by the BL, so really I just need a quick and dirty way to inject my classes into MVC’s DI.

Can someone please point me at a good tutorial?

What I’ve got at the moment….

Sub Application_Start()
    ...Snip...

    'Suggested in the link on jrummel's answer...
    GlobalConfiguration.Configuration.DependencyResolver = New WebResolver
    'It fails due to DependencyResolver not being defined


    'I do have a 
    GlobalConfiguration.Configuration.ServiceResolver = New WebResolver
    'but it's read-only and it is of type System.Web.Http.Services.DependencyResolver not IDependencyResolver

End Sub

Private Class WebResolver
    Implements IDependencyResolver

    Private Resolver As Common.Interfaces.IDependencyResolver = Core.DependencyResolverFactory.QuickResolver

    Public Function GetService(serviceType As Type) As Object Implements IDependencyResolver.GetService
        Return Resolver.Resolve(serviceType)
    End Function

    Public Function GetServices(serviceType As Type) As IEnumerable(Of Object) Implements IDependencyResolver.GetServices
        Return Resolver.ResolveAll(serviceType)
    End Function
End Class
  • 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-05T23:39:41+00:00Added an answer on June 5, 2026 at 11:39 pm

    ASP.NET Web API beta ships with its own IDependencyResolver, separate from MVC.

    There’s a tutorial on asp.net: Using the Web API Dependency Resolver

    You can get ServiceLocator from NuGet.

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

Sidebar

Related Questions

I have written a MVC3 application in which I use Valums fileuploader . When
Using an MVC3 .net controller on the back-end, I am performing an HttpPost to
Back in college I wrote a game where the computer would sleep for 1
Back in the days before Visual Studio Web Server we would host our local
back in school, we wrote a compiler where curly braces had the default behavior
I am using Ninject in MVC3 application. One of my resolvable dependencies makes use
I have published an ASP.NET MVC3 site. It runs great. However, looking back at
I have an MVC3 View that's posting back a set of input values via
As per : MVC3 Model binding pagedlist to ViewModel with custom EditorTemplate and Partial
in my ASP.NET MVC3 Project, I've got an action which runs a certain amount

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.