How to call C# webapi controller function when browser close
Can anyone tell me How to call C# webapi controller function when browser close(window.onbeforeunload) using anjular js.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Brijesh RathorRank #7,391 · 242 reputationPosted Nov 23, 2016, 11:44 PM EST
In your case its better to send a ajax request to do the task rather then redirecting the user to Web api controller.
Also send it on
onbeforeunloadOr a better idea will be add a
cookiewith user last activity. and check on every page load the if the last activity is more then the required limit server redirect to the login page clearing the session.Pradeep Singh154 reputationPosted Jan 11, 2017, 9:49 AM EST
Thiruppathi RRank #404 · 6.2K reputationPosted Jan 12, 2017, 8:23 AM EST