In this tutorial, we are going to show how to track user activity and how to log runtime errors.We can use filter attributes to mark any action method or controller. If the attribute marks a controller, the filter applies to all action methods in that controller.

Typically, we create an action or response filter by creating an attribute class that inherits from the abstract ActionFilterAttribute class.

Some built-in action filters, such as AuthorizeAttribute and HandleErrorAttribute, inherit from the FilterAttribute class.

Other action filters, such as OutputCacheAttribute, inherit from the abstract ActionFilterAttribute class, which enables the action filter to run either before or after the action method runs.

The following tutorial shows how to create a simple action filter that logs trace messages before and after an action method is called.

So Lets Create an ASP.NET MVC internet application project

Add a class TraceFilterAttribute that inherit from ActionFilterAttribute