Question Updating Modal 4.1.0 to 5.0.1
See original GitHub issueI am trying to update Blazor.Server Blazored.Modal from version 4.1.0 to the new version 5.0.1 and it is beating me up.
The 4.1.0 version works perfectly though. If I add your CascadingBlazoredModal component as you request when the application starts it crashes on the <app>
line in the _Host.cshtml below with a error of “InvalidOperationException: Blazored.Modal.BlazoredModal requires a cascading parameter of type IModalService”. Is there an issue with having two components wrapping the router in the App.razor file? How do I get around this issue?
The App.razor page already has a “CascadingAuthenticationState” component wrapping the router and has some additional parameters the application needs that are stored in your loacalStorage component.
`@code{ [Parameter] public string UserAgent { get; set; } [Parameter] public string IPAddress { get; set; } [Parameter] public string ServerUrl { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await localStorage.SetItemAsync("UserAgent", UserAgent);
await localStorage.SetItemAsync("IPAddress", IPAddress);
await localStorage.SetItemAsync("ServerUrl", ServerUrl);
}
}
} ` And then the _Host.cshtml has some code like below inside the body tags:
<app> <component type="typeof(App)" render-mode="ServerPrerendered" param-UserAgent="@Model.UserAgent" param-IPAddress="@Model.IPAddress" param-ServerUrl="@Model.ServerUrl" /> </app>
Orgbrat
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (5 by maintainers)
This fixed it for me.
@Orgbrat
Hi,
Might not be related to your problem, but check if you have removed the leftover
<BlazoredModal/>
from<MainLayout>
component.After upgrade to the new version I have added the new
<CascadingBlazoredModal/>
toApp.razor
wrapping the router and got tripped by this (App would crash (js interop excepctions), or double Modals would appear).