AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

Clarification on the role of Filter Attribute when used in Folders

Open Ponant opened this issue 4 years ago • 2 comments

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.

Ponant avatar Aug 10 '21 14:08 Ponant

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.

Ponant avatar Aug 10 '21 14:08 Ponant

@mkArtakMSFT please assign a reviewer.

Rick-Anderson avatar Apr 05 '22 02:04 Rick-Anderson