Tomas
Tomas

Reputation: 18117

Detect when user navigate from one web page to another

I am writing MVC3 web app I need to know at server side when user navigate from one web page to another. I do not need to know from what pages page to which just fact that user navigated. I could find this by adding Session variable to every Home Controller Actions but maybe there is better solution?

Upvotes: 0

Views: 426

Answers (2)

LockTar
LockTar

Reputation: 5467

Use a global filter attribute for al your controller actions. You can set that attribute in the global asax. In that case you know when an action is hit.

Upvotes: 1

Dmitry Reznik
Dmitry Reznik

Reputation: 6862

You could try sending AJAX request bound to onbeforeunload browser event.

Basically, it happens on the client side, so the programming should also be in client. Javascript could be the way to go. Though it may deliver some inconvenience to the user.

Upvotes: 0

Related Questions