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

Problem with app.razor, why can't I add the @code section?

$
0
0

razor

@inject IVisibilityService VisibilityService<CascadingAuthenticationState><Router AppAssembly="@typeof(Program).Assembly"><Found Context="routeData"><AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"><NotAuthorized><h1>Access Denied</h1><p>You are not authorized to access this resource.</p></NotAuthorized></AuthorizeRouteView></Found><NotFound><LayoutView Layout="@typeof(MainLayout)"><p role="alert">Sorry, there's nothing at this address.</p></LayoutView></NotFound></Router></CascadingAuthenticationState>@code {    private bool isActiveTab = true;    protected override async Task OnInitializedAsync()    {        VisibilityService.OnVisible += OnTabVisible;        VisibilityService.OnHidden += OnTabHidden;        await VisibilityService.Initialize();    }    private async void OnTabVisible()    {        // Example logic when tab becomes visible        Console.WriteLine("Tab is visible");    }    private async void OnTabHidden()    {        // Example logic when tab becomes hidden        Console.WriteLine("Tab is hidden");    }}

it keeps giving me an error:"RZ1006 The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. "as if he didn't like the mountain of code itself

I want to add logic that if the tab is not active, it should close the thread so as not to waste memory.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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