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

Add clarification about using Conventions when configuring AddRazorPages

Open marqdouj opened this issue 7 years ago • 1 comments

I've read the pdf from this link that was provided in a recent ASP.NET Community Standup: https://wakeupandcode.com/ The link indicates to me that I should be able to use Conventions with services.AddRazorPages.

I've created a blazor server app using the template provided and configured it to use authentication. I've moved FetchData.razor to a sub folder Pages/Authorized. I then tried both of these; neither which worked. services.AddRazorPages(o => o.Conventions.AuthorizeFolder("/Pages/Authorized")); services.AddRazorPages(o => o.Conventions.AuthorizePage("/fetchdata"));

If I added @attribute [Authorize] to FetchData.razor then it works.

So should I be able to use Conventions or not with blazor pages?


Document details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

marqdouj avatar Aug 11 '19 15:08 marqdouj

Hello @marqdouj ... That's not a supported scenario currently. The only supported approaches at this time for any Blazor scenario are in the Blazor docs.

As a general approach for documenting Blazor, we don't usually point out what can't be done simply because we'd have massive numbers of remarks 🙈 for all of the things that ... well ... can't be done. :smile: It would be a considerably long list of things to document and maintain. It would swamp the bits that Blazor can do—or do in a similar way. It's sort of a 'if you don't see it, it probably isn't supported' deal right now.

We try to keep the docs as up-to-date as possible. Certainly if you get wind of something that should be covered that you know works but don't see it, please do open an issue for that. We do miss scenarios, usually small ones, from time-to-time.

On a broader note, integration with RP/MVC solutions/projects doesn't go beyond what the docs currently describe for embedding a component in a page or view and SignalR. Other scenarios (e.g., dependency injection, Razor class libs, Data Protection, etc.) either work using the same infrastructure or a very similar infrastructure that's part of the Blazor framework.

If you search the engineering repo, you'll find devs asking about better integration between Razor Pages/MVC and Blazor. AFAIK, it's in-design at this time. I think that they're working on it. Hybrid solutions/projects aren't supported outside of hosting a client-side Blazor app by an ASP.NET Core app, which has no bearing on what you're asking about here. You're certainly welcome to find one (or more) of the open engineering issues that deal with this subject and lend your voice of support for the effort. If you haven't seen it yet, the engineering repo issues are here :point_right: https://github.com/aspnet/AspNetCore/issues

... and here's the link if you want to narrow that down to just the Blazor labeled issues ...

https://github.com/aspnet/AspNetCore/issues?q=is%3Aissue+is%3Aopen+label%3Aarea-blazor

guardrex avatar Aug 11 '19 16:08 guardrex