Khalid Omar
Khalid Omar

Reputation: 2402

How to store user activities on Asp.net Mvc website?

i have asp.net mvc2 simple web site and i have ms sql data base each user can use the website should log in ,i want to make new table and store in it user activities when user delete file or add new file navigate to any page new record add to the table, is there is away to put function before the program went to the controller to store user action sorry i'm new to that

Upvotes: 3

Views: 531

Answers (1)

Michael Stum
Michael Stum

Reputation: 180874

You want to create an ActionFilter:

public class ActivityLoggerActionFilter : ActionFilterAttribute {
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        // use filterContext to find out what is happening
    }
}

You then decorate your controller action with it:

public class YourController : Controller {

    [ActivityLogger]
    public ActionResult Index() {

    }

}

Upvotes: 2

Related Questions