我正在嘗試將Blazored.Modal與AuthenticationState一起使用。
我找不到任何說明如何在 App.Razor 檔案中組合這兩個屬性/鍵的檔案。
以下是我目前擁有 App.Razor 的方式:
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="@lazyLoadedAssemblies" OnNavigateAsync="@OnNavigateAsync">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (!context.User.Identity.IsAuthenticated)
.
.
.
</CascadingAuthenticationState>
我需要插入<CascadingBlazoredModal>某個地方,但我不知道。我試過在下面添加它,但這似乎創建了頁面的兩個渲染。我嘗試用 CascadingBlazoredModal 包裝上面的代碼,我嘗試將 CascadingBlazoredModal 放在 AuthenticationState 中。
我看到的唯一檔案是關于 CascadingValues/Params 的,但這不是我要找的。
任何幫助將不勝感激!
謝謝!
uj5u.com熱心網友回復:
我沒有測驗過這個,但是從檔案來看這應該有效:
<CascadingAuthenticationState>
<CascadingBlazoredModal>
<Router AppAssembly="typeof(Program).Assembly">
...
</Router>
</CascadingBlazoredModal>
</CascadingAuthenticationState>
您應該能夠在模態托管表單中獲取級聯值。
[CascadingParameter] public Task<AuthenticationState> AuthTask { get; set; }
uj5u.com熱心網友回復:
我讓它作業!不確定這是否是最好的選擇,但是......
我不得不包裹CascadingBlazoredModal周圍的Authenticationstate... AND內添加authenticationstate Found...
如果我不將整個應用程式包裝Router起來,AuthenticationState我將無法訪問整個應用程式,而只能訪問我使用(嘆氣)進行身份驗證的頁面。
<CascadingBlazoredModal>
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="@lazyLoadedAssemblies" OnNavigateAsync="@OnNavigateAsync">
<Found Context="routeData">
<CascadingAuthenticationState>
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</CascadingAuthenticationState>
</Found>
.
.
.
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/344043.html
