Dose Unity AOP support asp.net web application?

Jan 31, 2013 at 10:47 AM
Edited Jan 31, 2013 at 10:51 AM
actually, i want to intercept events and methods calls in each page
Feb 1, 2013 at 3:57 AM
You can definitely use Unity in a web application.

However, if you want to hook into ASP.NET WebForms page and control lifetimes to perform interception then that is not supported (due to the nature of ASP.NET design). For new development, ASP.NET MVC would be the preferred approach since it allows easy use of dependency injection. See http://mvcunity.codeplex.com/ or How To Use Unity Container In ASP.NET MVC Framework for some information of this approach.

Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Feb 1, 2013 at 9:28 AM
Thanks for your reply.

I also want to know if it is possible to intercept static methods in static class. I have seen your demo, but I find that creates a proxy for intercept instance method. So I would like to know if there are workarounds for interception without resolve an instance.

Sawyer,
Feb 1, 2013 at 4:17 PM
Unity interception is based around proxy objects or derived classes so you can't intercept static methods. When the compiler sees a static method call it compiles that call directly into the IL so there is nothing that can be done at runtime to intercept the method call.

To handle static method interception you can use an IL weaving tool to inject the interception code into the IL. A popular (paid) product for this is PostSharp although I haven't used their product.

Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to