Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All, I have a MVC web application. I need to implement a control which will show all the recent activities in the page. For example, if a user click a button, link or open a new page or tab all activities will be logged and will be shown in the control. One thing I can use the Activity filter to each action in the Controller to log the event and use a ajax call to log if page does not get refreshed. However it seems does not feasible. This feature is almost like the update section in the facebook. Is there any other approach in MVC ?
Posted
Updated 28-May-12 20:41pm
v2

MVC is irrelevant. Every time a page is requested, you can store in the DB that it was, by deriving all your controllers from your own base class, which stores this information on the way through for the user.
 
Share this answer
 
You should optimize the following solution by using database, the quick and dirty way is as follows. (Note: do not use the following way for production application, this is just for demo purpose, use database instead of session used in the example)

on every action in the controller add the following line at the top.

C#
Session['RecentActivity'] = Session['RecentActivity'].ToString() + ViewContext.Controller.ValueProvider["action"].RawValue + "-" +
ViewContext.Controller.ValueProvider["controller"].RawValue + "<br />";


and either create a partial view and add the following and then render the view in each view, or just add the following line to top of each view.

C#
<p> @Session["RecentActivity"].ToString() </p>


I have note tested the code, so just test it by adding it on few actions and few views.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900