How to store user actions on the Asp.net Mvc website?

I have a simple asp.net mvc2 website and I have a ms sql database, every user can use the site, must log in, I want to create a new table and save user actions in it when the user deletes a file or adds add a new navigation file to any new page entry in the table, is it possible to put a function before the program goes to the controller to store user actions it’s a pity that I am new to this

+3
source share
1 answer

Do you want to create an ActionFilter :

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

Then you decorate your action with the controller:

public class YourController : Controller {

    [ActivityLogger]
    public ActionResult Index() {

    }

}
+2
source

Source: https://habr.com/ru/post/1795085/


All Articles