Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Server app, JavaScript files stop working when trying to load blazor.server.js

$
0
0

I have a problem that I am facing while working with Blazor Server in .NET 8. My JavaScript scripts stop working correctly when I try to load the script

<script src="_framework/blazor.server.js"></script>

in the _Layout.cshtml file.When I include this script, my own JavaScript scripts stop working (they actually work for a fraction of a second, then the screen flickers and the scripts stop working). However, when I remove the references to .js files in _Layout.cshtml and place them directly in files like page1.razor, everything works fine.

File _Layout.cshtml:

<base href="~/" /><component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" /></head><body>    @RenderBody()<script src="js/test/custom.js"></script><script src="js/test/swiper.js"></script><script src="js/test/gallery.js"></script><script src="js/test/Pager.js"></script><script src="js/test/picture.js"></script><script src="js/main.js"></script><script src="_framework/blazor.server.js"></script>

I would like all my references to JavaScript files to be contained in the _Layout.cshtml file so that they are global and work correctly across the entire page. My JavaScript scripts are intended to trigger interactions, such as <div class="swiper-button-next">.

I have already searched through threads related to similar issues, including this one on StackOverflow, but I couldn't find a solution to my problem.

Has anyone encountered a similar issue and could help me? Maybe someone knows the solution to correctly load blazor.server.js in _Layout.cshtml so that my JavaScript scripts work properly across the entire page?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>