需要所有Blazor页面上的授权 [英] Require authorization on ALL Blazor pages
问题描述
我正在与Blazor一起玩,并创建了一个由服务器托管的Web应用程序.我必须在页面顶部放置一个@@ tribute [Authorize]这样的授权行,以确保用户已登录.
I am playing with Blazor and created a web app that is server hosted. I have to put an authorize line on top of the page like this @attribute [Authorize] to ensure the user is logged in.
似乎我必须将此行单独添加到每个页面.是否有全局设置来保护应用程序中的所有页面,当然除了登录页面.
It seems like I have to add this line to each page individually. Is there a global setting that protects ALL the pages in the app, except for the login page of course.
谢谢!
推荐答案
尝试将其添加到_Imports.razor.我认为应该可以...
Try to add it to _Imports.razor. I think it should work...
在登录页面中添加@attribute [AllowAnonymous]
In the login page add @attribute [AllowAnonymous]
从来没有做过.只是猜测而已.
Never did it before. It's only a guesswork.
这篇关于需要所有Blazor页面上的授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!