开发者

number of get requests

I would like to log how many get requests a user performed per day in asp.net mvc (3) after being for开发者_JAVA技巧ms authenticated. I suppose I could implement a ActionFilter or something but then I have to mark each relevant action/controller. Could I somehow intercept this globally? Thanks!

Christian


A global action filter perhaps?

Global.asax.cs

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();

    // Register global filter
    GlobalFilters.Filters.Add(new AuthenticatedHttpGetTracker());

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);
}

Action Filter:

public class AuthenticatedHttpGetTracker: ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext context)
    {
        // your logic to check if this request is an authenticated GET
        base.OnActionExecuting(filterContext);
    }
}

However, i dare say there could be a tool which tracks this for you at the server level, rather than code level.

Worth a google.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜