As per usual, I've been tweaking the exercises I'm doing. I just finished my current set on Friday, so I'll probably start a whole new routine next week. I've maxed out a few machines, so I'll either need to find a new exercise or a different machine.
Continue reading "Strength Training: July" »
In my last blog post, I introduced you to the new Global Filters feature that is part of ASP.NET MVC 3 (Preview 1). Such filters run for every single request in the system.
The registration API makes it obvious that you're using a single instance of an object, so your filters should not be stateful (that is, since the single instance is shared through all requests, you will not be able to store any pre-request data inside the filter itself).
Continue reading "ASP.NET MVC Filters and Statefulness" »
Series Index
Important Update
We've made significant changes to the IoC support in ASP.NET MVC 3 Beta. Please read Part 5 for more information.
Filters and Filter Providers
We introduced the concept of filters in ASP.NET MVC 1.0. A filter can implement one of more of the following interfaces: IActionFilter, IResultFilter, IExceptionFilter, and IAuthorizationFilter.
In prior versions of MVC, the only way to apply filters was to make a filter attribute and apply that attribute to a controller or an action method. In MVC 3, we've introduced the ability to have filters which are defined outside the scope of attributes (and found via filter providers), as well as a facility for registering global filters.
Update: (31 July 2010) I've added the source code for UnityMvcServiceLocator to the end of part 2.
Continue reading "ASP.NET MVC 3 Service Location, Part 4: Filters" »
Series Index
Important Update
We've made significant changes to the IoC support in ASP.NET MVC 3 Beta. Please read Part 5 for more information.
View Engine Registration and View Page Creation
ASP.NET MVC 1.0 introduced View Engines (implementing IViewEngine and IView), shipping with the single WebForms-based view engine. Views, master pages, and partial views in WebForms view engine need to derive from ViewPage, ViewMasterPage, and ViewUserControl (respectively). In MVC 3, we've introduced new dependency injection points for all of these classes (plus the new base class for Razor views, WebViewPage).
Update: (31 July 2010) I've added the source code for UnityMvcServiceLocator to the end of part 2.
Continue reading "ASP.NET MVC 3 Service Location, Part 3: View Engines/View Pages" »
Series Index
Important Update
We've made significant changes to the IoC support in ASP.NET MVC 3 Beta. Please read Part 5 for more information.
Controller Creation
The most common form of service location today in ASP.NET MVC is for controller creation. In MVC 1.0, we created an interface named IControllerFactory which is responsible for the location and creation of controllers. This interface was introduced with the explicit desire to support dependency injection of controllers.
Update: (31 July 2010) I've added the source code for UnityMvcServiceLocator to the end of this post.
Continue reading "ASP.NET MVC 3 Service Location, Part 2: Controllers" »
Series Index
Important Update
We've made significant changes to the IoC support in ASP.NET MVC 3 Beta. Please read Part 5 for more information.
Introduction
One of the new features in ASP.NET MVC 3 is the ability to register a service locator that will be used by the framework. Prior versions of the MVC framework have offered opportunities for introducing concepts like service location and dependency injection (DI); in MVC 3, we have formalized the process and opened up several new opportunities for developers.
This first post in the series will discuss the general strategy for service location in MVC 3. Later posts will discuss specific ways to perform service location and DI with existing and new features.
Continue reading "ASP.NET MVC 3 Service Location, Part 1: Introduction" »
In ASP.NET MVC, getting your routes setup properly can be tricky if you have a lot of routes. Whenever something is tricky, and might be touched often, having a set of unit tests around it can very helpful to ensure you aren't breaking it when you make changes. Lots of routes can definitely qualify; your users rely on unbroken links and stable URLs for a good experience.
The techniques shown here not only work for unit testing, but can also be used outside of the ASP.NET pipeline when you need to interact with the routing system (for example, to generate URLs from a service). The routing system used by ASP.NET MVC uses the abstraction classes, so the actual running ASP.NET pipline isn't required.
Continue reading "Testing Routing and URL Generation in ASP.NET MVC" »
Apparently I forgot about May. :) I've swapped some exercises in and out, and I've added a 10 minute fast walk at the end of the workout (at least 3 MPH and a 6-7 degree incline). Since my heart rate is already up at the end of the strength training, this is a quick way to work on cardio capacity without being insane about it. Most things had leveled out, so the gains are a lot slower now.
Continue reading "Strength Training: June" »