OnLeave Razor Page Event

miladel

Member
Joined
Aug 16, 2020
Messages
14
Programming Experience
Beginner
Dear All,
I need to perform a task when the user leaves a page(not the whole application) in razor pages, just opposite the OnGet method.
Is there any solution? Any help would be appreciated.
 
Technically, web pages don't know when a user is leaving a page. Does changing focus to another tab count as leaving a page? Does refreshing the page count as leaving a page? Does closing a tab count as leaving a page? Does killing a browser using Task Manager count as leaving a page? Does turning off the computer count as leaving a page?

In most cases there is nothing you can do in just plain old Razor or the HTML generated by Razor. Some of the cases can be handled by using JavaScript, but then this now becomes a JavaScript question, rather than a Razor question.
 
Technically, web pages don't know when a user is leaving a page. Does changing focus to another tab count as leaving a page? Does refreshing the page count as leaving a page? Does closing a tab count as leaving a page? Does killing a browser using Task Manager count as leaving a page? Does turning off the computer count as leaving a page?

In most cases there is nothing you can do in just plain old Razor or the HTML generated by Razor. Some of the cases can be handled by using JavaScript, but then this now becomes a JavaScript question, rather than a Razor question.
First of all thanks for your reply,
About what you have asked:
Does changing focus to another tab count as leaving a page?
Does refreshing the page count as leaving a page?
Does closing a tab count as leaving a page?
Does killing a browser using Task Manager count as leaving a page?

Does turning off the computer count as leaving a page?
Yes, All of the above conditions could be counted as leaving and they could be very helpful if I can understand when the user does these jobs. Besides these conditions, I need to know when the user navigates to another page, and as you said I may need to ask it as a javascript question. I just google it and find these results:
 
Back
Top Bottom