Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plans to make it Blazor Server-Side compatible? #2

Open
CoSJay opened this issue Mar 27, 2020 · 11 comments
Open

Any plans to make it Blazor Server-Side compatible? #2

CoSJay opened this issue Mar 27, 2020 · 11 comments

Comments

@CoSJay
Copy link

CoSJay commented Mar 27, 2020

This is exactly what I need (I have no idea why the Blazor folk didn't include it!), but as client-side Blazor isn't released yet we can't use it for production apps -- we're doing everything server-side. Any thought to making this SSB-friendly?

@peterblazejewicz
Copy link
Owner

@CoSJay
I'm most accustomed to client-side blzr, let me look into the problem for server side. Thanks!

@pentiv
Copy link

pentiv commented Jul 23, 2021

Hi peter,

do you have any solution, blazor server side web assembly.

#2

please let me know that will be great help.

@peterblazejewicz
Copy link
Owner

can't promise, I need to refresh local stack, tbu

@jmarinl
Copy link

jmarinl commented Oct 10, 2021

Please help me on blazor server. Error. Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: blazejewicz.Blazor.BeforeUnload.BeforeUnload Lifetime: Singleton ImplementationType: blazejewicz.Blazor.BeforeUnload.BeforeUnload': Cannot consume scoped service 'Microsoft.JSInterop.IJSRuntime' from singleton 'blazejewicz.Blazor.BeforeUnload.BeforeUnload'.)

@peterblazejewicz
Copy link
Owner

@jmarinl which version of .net you're on at the moment? (note, this one was never run properly on server-backed blazor version)

@girlpunk
Copy link

girlpunk commented Mar 2, 2022

Replacing services.AddBeforeUnload(); with services.AddScoped<BeforeUnload>() removes the exception, however the callback doesn't get run when navigating off the page.

@TheCollegedude
Copy link

Hi, has anyone found a solution?

@jamesw98
Copy link

Bump
This looks like a perfect solution to what I'm trying to do right now, but am running into the same issue as @girlpunk

@IIV21
Copy link

IIV21 commented May 19, 2023

Has anyone found a solution to using this in a blazor server?

@IIV21
Copy link

IIV21 commented May 23, 2023

The new dotnet 7 updates regarding blazor implement wich implements 2 methods
1 for internal routing (when the user navigates inside the app)
1 for external routing (when the user navigates outside the app, closes the web page or refreshes)

@decimvs
Copy link

decimvs commented Nov 17, 2023

Starting from ASP .NET 7 you no longer needs to use an external library to do so. You could use the built-in event notifier and component:

  • RegisterLocationChangingHandler -> lets you to register a handler that is called before navigating an internal link. It lets you the posibility to cancel navigation.
  • NavigationLock component -> registers an beforeunload event listener in the window object of the browser. It's intended for external navigation, tab or window closing.

More info at MS Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants