MVC/Unity - How to inject dependencies into custom FilterAttributes?
问题 I Have a custom HandleErrorAttribute that extends FilterAttribute . How can I have Unity inject dependencies into this attribute at the same time that it injects the controller's dependencies itself? 回答1: Ok, figured it out. Mostly I used Ben's solution above from the blog post he pointed to. The problem is that Unity behaves a little differently. You can't inject dependencies on the filters directly, because they are of type IActionFilter and IExceptionFilter respectively. This led me to