Razor Pages ConfigureFilter does not work on Areas
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is your feature request related to a problem? Please describe.
Configuring Filters for Razor Pages does not work on areas.
i.e. the following will not work for areas:
`options.Conventions.ConfigureFilter(model => new AdminDomainFilterFactory(model));`
### Describe the solution you'd like
I think it should be added to the documentation.
that this is not possible.
Currently a workaround would be adding that:
```
public static IPageApplicationModelConvention ConfigureAreaFilter(
this PageConventionCollection conventions,
string areaName,
Func factory)
{
if (areaName == null)
throw new ArgumentNullException(nameof(areaName));
if (conventions == null)
throw new ArgumentNullException(nameof (conventions));
if (factory == null)
throw new ArgumentNullException(nameof (factory));
return conventions.AddAreaFolderApplicationModelConvention(areaName, "/", (Action) (model => model.Filters.Add(factory(model))));
}
```
a better solution of course would be if it would work on **all** areas
which is possible by implementing a `IPageApplicationModelConvention` that does not filter out the areaName.
Contributor guide
Assessment
This issue has not been assessed yet.