Articles : Page 2 of 2

  • Dependency Injection in ASP.NET MVC: Views

    Dependency Injection in ASP.NET MVC: Views

    May 10
    19

    Other posts in this series: Controllers Contextual controller injection Filters Action Results And now for a bit more controversial shift. While most folks doing DI in ASP.NET MVC see the benefit of the ability to provide injection around the controller-side of things (filters, action results, controllers etc.), I’ve also seen a lot of benefit from injection on the view side. But before delve into the how, let’s first look at the why. The responsibility of a view is to render a model...


  • MvcExtensions – Custom Service Registration

    MvcExtensions – Custom Service Registration

    May 10
    16

    [Special Note: I have just released SP1 Preview which contains the newly added Autofac Adapter and minor Windsor changes] In this post, I will show you how you can register your custom services in your preferred IoC container and how the MvcExtensions will integrate it with the rest of the application. One of the goal of MvcExtensions is, unlike the other mvc add-on library which provides its own custom interface for registration/resolution, it will let you use your container syntax that you...


  • Announcing the RTM of MvcExtensions (aka System.Web.Mvc.Extensibility)

    Announcing the RTM of MvcExtensions (aka System.Web.Mvc.Extensibility)

    May 10
    11

    I am proud to announce the v1.0 of MvcExtensions (previously known as System.Web.Extensibility). There has been quite a few changes and enhancements since the last release. Some of the major changes are: The Namespace has been changed to MvcExtensions from System.Web.Mvc.Extensibility to avoid the unnecessary confusion that it is in the .NET Framework or part of the ASP.NET MVC. The Project is now moved to CodePlex from the GitHub. The primary reason to start the project over GitHub was di...


  • Dependency Injection in ASP.NET MVC: Action Results

    Dependency Injection in ASP.NET MVC: Action Results

    May 10
    04

    On a recent, very large project, we started to notice a distinct trend in our controllers. All of our “POST” actions started to look very similar. Check form validation, run business rule validation. If validation succeeds, execute the actual business logic. If it fails, just show the view with the original form. The problem we ran into was how to encapsulate this common behavior. We first went with some abomination of a base, CRUD controller. I should have listened to the OO luminaries, “Fa...

    • DependencyInjection

  • Dependency Injection in ASP.NET MVC: Filters

    Dependency Injection in ASP.NET MVC: Filters

    May 10
    03

    So far, we’ve looked at extending the advantages of dependency injection to our controllers and its various services. We started with a basic controller factory that merely instantiates controllers to one that takes advantage of the modern container feature of nested/child containers to provide contextual, scoped injection of services. With a child container, we can do things like scope a unit of work to a request, without needing to resort to an IHttpModule (and funky service location issues)...

    • DependencyInjection

  • Dependency Injection in ASP.NET MVC: Contextual controller injection

    Dependency Injection in ASP.NET MVC: Contextual controller injection

    Apr 10
    28

    In the last post, we looked at the basic DI usage in ASP.NET MVC – instantiating controllers. However, there are quite a few other things we can do with controllers besides merely instantiate them. One thing to keep in mind with the Controller base class is that although you can inject your controller’s dependencies, quite a few others are around via properties. For example, the IActionInvoker and ITempDataProvider are two replaceable services the base Controller class uses to do its work, b...

    • DependencyInjection

  • Dependency Injection in ASP.NET MVC: Controllers

    Dependency Injection in ASP.NET MVC: Controllers

    Apr 10
    27

    After working for 5 years with WebForms, it was quite a breath of fresh air to deal with simple controllers and actions with MVC. Even better was that there is support for IoC containers built in to the framework. However, support for dependency injection does not run very deep in an explicit manner, and some work is required to get your container to take as much control as possible over locating instances of objects. Dependency injection is one of the most powerful tools in any advanced d...

    • DependencyInjection