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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:08:45+00:00 2026-05-19T09:08:45+00:00

Possible Duplicate: What is IOC? Need some practical code examples to illustrate I have

  • 0

Possible Duplicate:
What is IOC? Need some practical code examples to illustrate

I have heard IOC banded about a lot but I’m still not entirely sure what it is and why I would want it. My naive understanding is that it somehow gives you control but I’m not sure what.

I know Castle Windsor is the popular product for ASP.Net MVC but I dont understand what it does. It seems to override the default way ASP.Net MVC handles requests for controllers.

I’m starting a MVC app with Fluent NHibernate and trying to get it configured but all posts seem to suggest using Castle Windsor as well.

Could you please explain exactly what IOC is and why I would want to use Castle Windsor in a ASP.Net MVC app?

Thanks

  • 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-19T09:08:46+00:00Added an answer on May 19, 2026 at 9:08 am

    IoC in general and Castle Windsor in particular will not help you until you try. Concept is well described in MVC 2 in Action book. Here is a citate:

    One common technique when building
    applications is to pass application
    dependencies into the constructor of
    the controllers. By leveraging various
    tools, we can automatically wire up
    these dependencies and provide the
    arguments without having to write
    mundane, repetitive code. To enable
    this for our controllers, we need to
    take responsibility for creating them…

    …

    The Inversion of Control principle and dependency injection

    Normally when code executes other
    code, there’s a linear flow of
    creation and execution. For instance,
    if I have a class that depends on
    another class, I will create that
    class with the new operator, and then
    execute the class by calling a method.
    If I used Inversion of Control (IoC),
    I’d still call methods on the class,
    but I’d require an instance of the
    class passed into my constructor. In
    this manner, I yield control of
    locating or creating my dependency to
    the calling code. Dependency injection
    (DI) is the act of injecting a
    dependency into a class that depends
    on it.

    Often used interchangeably, IoC
    and DI yield loosely coupled code and
    are often used with interfaces. With
    interfaces, classes declare
    dependencies as interfaces in the
    constructor arguments. Calling code
    then locates appropriate classes and
    passes them in when constructing the
    class.

    IoC containers come into play
    to assist with managing this technique
    when used through an application.
    There are plenty of IoC containers to
    choose from, but the favorites at this
    time seem to be StructureMap
    (http://structuremap.sourceforge.net),
    Ninject (http://ninject.org), and
    Castle Windsor
    (http://www.castleproject.org/container).
    Controllers can leverage dependency
    injection by declaring their
    dependencies as constructor
    parameters. This inverts the control
    so that the caller is responsible for
    supplying the dependencies of a class,
    rather than the class constructing
    concrete instances itself. It allows
    you to decouple controllers from
    concrete instances of its dependencies
    (such as a repository or service).
    It’s quite liberating, not to mention
    that it helps facilitate decoupled
    unit testing.

    When we ask for
    dependencies in the constructor, we
    call it constructor injection. There’s
    another technique called property
    injection, but it isn’t as apparent
    that these dependencies are required
    for the object to do its job. IoC
    tools can usually do both, but
    constructor injection is preferred for
    required dependencies.

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

Sidebar

Related Questions

No related questions found

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.