2

My Blazor app has some problem with Blazored-modal. If i try to show a modal pop as soon as someone visit the app, the modal pop up is not showed correctly and the console show this message:

Failed to load resource: the server responded with a status of 404 (Not Found) blazored-modal.css:1 

Any other popup is correctly showed and the error message is no more present in the console.

All is setted properly:

Configuredservices:

public void ConfigureServices(IServiceCollection services)
    {
        services.AddRazorPages();
        services.AddServerSideBlazor();
        services.AddSingleton<WeatherForecastService>();
        services.AddBlazoredModal();
    }

_Imports:

@using Blazored.Modal
@using Blazored.Modal.Services

App.razor:

<CascadingBlazoredModal>
<Router AppAssembly="@typeof(Program).Assembly">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
    </Found>
    <NotFound>
        <LayoutView Layout="@typeof(MainLayout)">
            <p>Sorry, there's nothing at this address.</p>
        </LayoutView>
    </NotFound>
</Router>

_Host.cshtml

@page "/"
@namespace StampaManualeEtichetteAggiuntive.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
<title>StampaManualeEtichette</title>
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
</head>
<body>
<app>
    <component type="typeof(App)" render-mode="ServerPrerendered" />
</app>

<div id="blazor-error-ui">
    <environment include="Staging,Production">
        An error has occurred. This application may no longer respond until reloaded.
    </environment>
    <environment include="Development">
        An unhandled exception has occurred. See browser dev tools for details.
    </environment>
    <a href="" class="reload">Reload</a>
    <a class="dismiss"></a>
</div>

<script src="_framework/blazor.server.js"></script>
<script src="_content/Blazored.Modal/blazored.modal.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font- 
awesome/5.15.1/css/all.min.css">
<script src="css/font-awesome/js/all.min.js"></script>
</body>
</html>

And in my Index.razor

[CascadingParameter] public IModalService Modal { get; set; }

Can some one help me solving the problem?

Simon3
  • 89
  • 1
  • 10
  • This was a month ago, but I'm curious to know if you have found your problem? I don't have this issue, but I do use BlazoredModal, so if I ever see this issue, I hope to find the solution here, if it exists. :) – Shuryno Nov 26 '21 at 19:08
  • Hi, not really. The error appears once in a while so this is not a real problem. i think is somethings linked with some timeout. i have created a discussion on the official blazored github page but no one can help me with this problem. – Simon3 Nov 29 '21 at 16:07
  • I knew this would be an issue I would face, I have the exact same issue. When I use Modal.Show instead of navigating to my page, I seem to be loosing css information, these are in CSS isolated file. Its very strange. I will look into it. Interesting that you say it only appears once in a while, I seem to have it as soon as I use Modal.Show. – Shuryno Feb 01 '22 at 22:17
  • 1
    The error is showed every time you use modal.show()? For me the error is showed only on the frist modal.show ( called as soon as the page is loaded). Probably ,sometimes, a component is loaded with a small dalay that cause the errore for the modal.show. I'm not sure but that could be an explaination. – Simon3 Feb 03 '22 at 15:41
  • 1
    Ah yes, I have found my issue. I was using cascading parameter for the theming, but now that its a modal, its doesn't receive the cascading value. Had to pass the value as modal parameter. – Shuryno Feb 03 '22 at 17:44
  • Oh, i will check my code just to be sure. But i think we have differet problem with the same result Thank you – Simon3 Feb 07 '22 at 16:10

0 Answers0