9
votes

I am trying to lock access to all the pages in selected Areas in my Razor Pages app. So far I have this sample structure

Areas

  • Account

    • Index.chtml
  • Business

    • Index.chtml

If I add

options.Conventions.AuthorizeFolder("/business", "/index"); 

to startup, it works on a per page basis, but I cant see any clear way to lock the entire Business folder. I've tried the folder based options mentioned here

https://docs.microsoft.com/en-us/aspnet/core/security/authorization/razor-pages-authorization?view=aspnetcore-3.0

but none seem to work. Is this even possible?

1

1 Answers

16
votes

So 10 seconds after asking, this works

options.Conventions.AuthorizeAreaFolder("business", "/");