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

How can my Blazor method tell if the page it's running on has been navigated away from?

$
0
0

I've got a Blazor page where the user can start a long-running (~10 minute) process that downloads multiple files from a vendor's API, combines them into a zip archive, and downloads the zip archive to the user's computer. Currently, if the user navigates away from the page, the process continues running but I need it to stop.

I originally thought I could use the beforeunload or unload events but everything I've read says to absolutely not use those. (I have almost no JavaScript experience--that's why we're using Blazor.)

How can I either get a notification that the page has been navigated away from or have the process test to see if the page still exists?

Update

I found NavigationManager.RegisterLocationChangingHandler which works for page navigation but not for closing a tab or refreshing the page. So I still need a way to find out if the page still exists or not.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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