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

Blazor Layout subfolder results in infinite loop

$
0
0

I've created a new blazor server app (default Microsoft example template in Visual studio for Mac). Then in the Page folder, I've created a new subfolder "Test". Within the subfolder "Test" I've created the following files:

_Imports.razor

@layout TestTemplate

TestTemplate.razor

@inherits LayoutComponentBase<h1>Test layout</h1>@Body

Index.razor

@page "/test"<h3>Hello test layout</h3>@code {}

When I build the solution, no errors are found. But when I open a browser and go the the url http://localhost:portnr/test, my browser keeps on rendering/hangs (infinite loop I think).

According to this document from Microsoft https://learn.microsoft.com/en-us/aspnet/core/blazor/components/layouts?view=aspnetcore-6.0 The above steps should work (see section "Apply layout to a folder".

I've checked the _Imports.razor file at the root of the project to see if there is an other reference to @layout because according to the above link this would result in an infinite loop. And the App.razor contains a reference to the MainLayout:

<Router AppAssembly="@typeof(App).Assembly"><Found Context="routeData"><RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /><FocusOnNavigate RouteData="@routeData" Selector="h1" /></Found><NotFound><PageTitle>Not found</PageTitle><LayoutView Layout="@typeof(MainLayout)"><p role="alert">Sorry, there's nothing at this address.</p></LayoutView></NotFound></Router>

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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