Chapter 4. Before and after: boundary aspects

This chapter covers

  • What boundaries mean
  • Using PostSharp to bound methods
  • Writing an ASP.NET HttpModule to help detect mobile users
  • The differences (and similarities) of method interception and method bounding
  • Writing a caching aspect with PostSharp

In chapter 3, I covered one of the most common types of method aspects you can write: method interception. These aspects contain code that runs instead of the code that it intercepts.

Another type of aspect you might use is a boundary aspect, which contains code that runs around the code that it’s bounding. (Most commonly, these aspects are methods, but other types of boundaries exist, including page requests, ASP.NET MVC controller actions, ...

Get AOP in .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.