Make all action methods of a controller ChildActionOnly <p>Instead of having to remember to decorate a bunch of action methods with the <code>ChildActionOnly</code> attribute, it would be convenient to be able to specify all methods in an entire controller as such.</p> <p>Trying to put the <code>ChildActionOnly</code> attribute on the controller class doesn't work (at least in my code context) because during dependency injection for the controllers, which occurs at an early phase in the request pipeline, there is no HttpContext or Request object, and the error "Request is not available in this context" is thrown.</p> <p>Could I create a <code>RouteConstraint</code> that makes the route itself enforce <code>ChildActionOnly</code>? That seems doubtful because of the same request pipeline issue--I don't know if the HttpContext would be available during the time that execution of RouteConstraints occurs. If you have ideas how to implement this, please share.</p> <p>Maybe create a unit test that uses reflection to discover all action methods of a specific controller and ensure they have the <code>ChildActionOnly</code> attribute set...</p> <p>How do I accomplish this? Could you give some starter code (doesn't have to be polished or even working, just a starting point will help).</p>