Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Big Rock: Filters for Razor Pages #6070

Closed
5 of 6 tasks
rynowak opened this issue Apr 4, 2017 · 5 comments
Closed
5 of 6 tasks

Big Rock: Filters for Razor Pages #6070

rynowak opened this issue Apr 4, 2017 · 5 comments

Comments

@rynowak
Copy link
Member

rynowak commented Apr 4, 2017

Pages should use basically the same filter types as controllers, but should expose some unique functionality in place of action filters. In general a pages developer will want to accomplish the same kinds of things with filters as a controller/action developer.

This includes:

  • authorization (authZ filters)
  • middleware-like behavior (resource filters)
  • scoped exception handling (exception filters)
  • decorating the execution of results (result filters)
  • manipulating action arguments (action filters)

We'll want to provide a little something extra for pages, likely to do with manipulating handler methods 👍

There's a lot more to do here, because designing a new filter type, we need to decide how filters get configured when you have a mix of pages/page-models/handler-methods/application-model.

Related items:

@rynowak rynowak self-assigned this Apr 4, 2017
@rynowak rynowak modified the milestones: 2.0.0-preview1, 2.0.0-preview2 Apr 4, 2017
@rynowak rynowak modified the milestones: 2.0.0-preview2, 2.0.0-preview3 May 30, 2017
@rynowak
Copy link
Member Author

rynowak commented Jun 27, 2017

Everything in this list is done or in PR, so closing this issue.

@sketchpunk
Copy link

Is there an example of how to use this? I was using RazorPagesOptions.AuthorizeFolder for force authorization on pages but now thats not supported in the final release. Thanks.

@pranavkm
Copy link
Contributor

@sketchpunk we moved the methods to hang off RazorPagesOptions.Conventions. You should be able able to options.Conventions.AuthorizeFolder(..). Additionally, applying the Authorize on page model is also supported now.

@sketchpunk
Copy link

@pranavkm thanks man, been looking all day and couldn't find where the methods moved to or what replaced them. Just one more question, I dont use a page model, but I do use the inline model. I added "using Microsoft.AspNetCore.Authorization" to my razor page and tried putting Authorize on OnGet but it doesn't do anything but it compiles just fine. Not sure if even meant to work in the inline model. Thanks for your help.

@pranavkm
Copy link
Contributor

@sketchpunk the attribute has to be on a type not on handler methods. For instance https://github.com/aspnet/Mvc/blob/dev/test/WebSites/RazorPagesWebSite/ModelWithAuthFilter.cs#L10.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants