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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Thiruppathi RPosted Jan 12, 2017, 1:23 PM
Pradeep SinghPosted Jan 11, 2017, 2:49 PM
Brijesh RathorPosted Nov 24, 2016, 4:44 AM
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.