Hello,
I'm creating a page with Blazor Server. I want to log in with Azure AD from a button in the top right corner. When the page launches, it automatically forces the login to Azure. I want this to happen when I press the Login button.
In this case you need your default/start page to be accessible by everyone (without Authorize attribute).
And to add the Login button do the following:
- Open MainLayout.razor and paste this above
<RadzenProfileMenu>
<RadzenButton Text="Login" Visible="@(!Security.IsAuthenticated())" Click="@Login" />
- Add this method to MainLayout.razor.cs:
protected void Login() { NavigationManager.NavigateTo($"Account/Login?redirectUri={NavigationManager.Uri}", true); }