Mvc: Rationalize what happens when you have filter attributes on a page model or handler method

Created on 27 May 2017  路  3Comments  路  Source: aspnet/Mvc

Right now any filter attributes on a pagemodel class or handler method are just ignored.

If we can't support this we should make it throw.

3 - Done enhancement feature-Razor-Pages

All 3 comments

Discussed with @rynowak ...

  1. Can decorate a PageModel with filters, and they will work as expected
  2. Cannot use filters within the CSHTML file because there's no syntax for that. Might happen in the future
  3. Will not try to detect "improper" usage of filters. If you're holding it wrong, you're holding it wrong.

Assigning this to the person already working on it https://github.com/aspnet/Mvc/pull/6417

Hey @pranavkm, I just found this issue via 8df30325407be3d3c30c850e6f63b1d2969b1dea and have a question:

I am trying to retrieve the filter metadata for a razor page by inspecting the action descriptors from IActionDescriptorCollectionProvider. However, due to this line, the filter descriptor collection is always empty.

This works perfectly fine for controller actions but from the change it seems that this only works from within the CompiledPageActionDescriptor? Is this really intended that page actions are incompatible to this filter metadata infrastructure? What would be the way to retrieve all page actions then including the applied filters?

Was this page helpful?
0 / 5 - 0 ratings