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

  • Home
  • SEARCH
  • 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 4120638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:14:53+00:00 2026-05-20T23:14:53+00:00

Is it possible to inject dependencies into an MVC ViewPage (must support layout pages)

  • 0

Is it possible to inject dependencies into an MVC ViewPage (must support layout pages) without using DependencyResolver?

I would rather not use DependencyResolver at all (I had major problems when injecting NH sessions into ActionFilters in the past (leaking all over the place)). However, I’m not sure if there is an alternative?

The other complexity I have is that the DependencyResolver needs to be tenant aware (each tenant has its own (StructureMap) container). I’m currently doing this by passing in a lazy instance of my tenant container resolver (seems this is necessary otherwise the resolver is cached):

public SmDependencyResolver(Func<ISiteContainerResolver> containerResolver)
{
    this.containerResolver = containerResolver;
}

public object GetService(Type serviceType)
{
    var container = containerResolver().Resolve();

If I end up using DependencyResolver should I ditch my StructureMap controller factory since it looks like DependencyResolver handles this too?

Thanks
Ben

  • 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-05-20T23:14:53+00:00Added an answer on May 20, 2026 at 11:14 pm

    Given that the DependencyResolver is used by so many aspects of the ASP.NET MVC framework for dependency injection your life will be easier if you use it – as you say it means you don’t need your own versions of things like the controller factory.

    That said, the framework is very flexible and it is always open for you to plug in your own version of things – I just prefer to create as little of my own code as possible on the KISS principle.

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

Sidebar

Related Questions

Is is possible to inject IPrincipal using Castle Windsor into my asp.net mvc controller.
Is it possible to inject ejb's into pojo's using the @EJB annotation? If it
Is it possible to inject EJB 3.1 beans into POJO using CDI on Glassfish
Is it possible to inject an interface into an existing 3rd party class that
Is it possible to inject an instance of logger class object using Managed Extensibility
Is it possible to inject a javascript file into the DOM and immediately execute
Is it possible to have Spring inject the JPA entityManager object into my DAO
As part of Spring 3 MVC it is possible to inject the currently logged
Is it possible to inject Spring beans into an RestEasy @Path class? I managed
With the new EJB 3.1 spec is it possible to inject an EJB into

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.