AspNetCore.Docs
AspNetCore.Docs copied to clipboard
Clarification on the role of Filter Attribute when used in Folders
This tutorial is great but there is something I am not sure if it is OK or bad practice.
I naively took the Filter Attribute and tried to use it globally in the Movies,
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages(options =>
{
options.Conventions.AddFolderApplicationModelConvention(
"/Movies",
model => model.Filters.Add(new AddHeaderAttribute("Author", "Rick")));
});
}
And it works! Is that OK, and if so what would be the problem, if any, or limitation? I am happy to update the docs to mention this, if that is an OK practice.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: f0646a3d-a5d1-d4b0-5494-fe38219d16c9
- Version Independent ID: 8b659e63-93b8-a496-bc9b-dce0d9fa8f3c
- Content: Filter methods for Razor Pages in ASP.NET Core
- Content Source: aspnetcore/razor-pages/filter.md
- Product: aspnet-core
- Technology: aspnetcore-razorpages
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
Motivation behind this question:
I already have a ResultFilterAttribute with logic in it that can be applied on indivudual pages. Implementing the same logic on a folder will require me to virtually duplicate the logic, hence the question.
@mkArtakMSFT please assign a reviewer.