dotnet-presentations / blazor-workshop

Blazor workshop
https://aka.ms/blazorworkshop
MIT License
3.47k stars 1.54k forks source link

MyOrders Component Authorization process #366

Open NewHeight opened 10 months ago

NewHeight commented 10 months ago

Since /myorders was not decorated with [Authorize] Attribute. So I think, type /myorders page in browser address bar, this page will acess the /orders api, then get 401 , the blazor redirect to login page. But I haven't seen the /orders api request in network panel. So what's the real authorization process of the page for /myorders ?

dotnetspark commented 10 months ago

This is the intended behavior. The attribute will execute first and if authenticated will continue to the component. Since you're not authenticated it redirects you to the login page

NewHeight commented 10 months ago

I follow the steps in Session #6, and I did not add [Authorize] Attribute to "/myorders" page. But if I access this page, it still redirect to login page. So I'm wondering what is working with the redirect?