Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:59:53+00:00 2026-06-13T03:59:53+00:00

I am implementing a logger that should capture details through an action filter for

  • 0

I am implementing a logger that should capture details through an action filter for the purposes of user activity recording and fault finding.

   public interface ISessionLogger
    {
        void LogUserActionSummary(int sessionId, string userActionType);    
        void LogUserActionDetail(int session, string userActionType, DateTime userActionStartedUtc, long actionDurationInMilliseconds, string queryParams, string referredFrom);
    }

I would like queryParams to capture all keys and values from the form collection, route values, action params, json calls and the querystring, which sounds like I would need

filterContext.Controller.ValueProvider

but it doesn’t seem possible to loop through this. So in my FilterAttribute I have

public void OnActionExecuting(ActionExecutingContext filterContext)
{
    var paramList = new List<string>();
    if(filterContext.ActionParameters != null)
    {
        paramList.AddRange(filterContext.ActionParameters.Select(param => String.Format("{0}:{1}", param.Key, param.Value.ToString())));
    }
    if(filterContext.Controller.ValueProvider != null)
    {
        //loop through the valueprovider and save the key value pairs to paramList
    }

    _queryParams = string.Join(",", paramList);
}

Is there another way to achieve this within the OnActionExecuting method of an action filter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:59:55+00:00Added an answer on June 13, 2026 at 3:59 am

    Why don’t you simply log the entire Request body? This way you will have everything you need to reconstruct the user request.

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var stream = filterContext.HttpContext.Request.InputStream;
        var data = new byte[stream.Length];
        stream.Read(data, 0, data.Length);
        Log(Encoding.UTF8.GetString(data));
    }
    

    As an alternative you could try logging all filterContext.HttpContext.Request.Params values as well as filterContext.RouteData values:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Due to the flooding examples of implementing logger using Singleton pattern, I have just
I was implementing my Logger class but for a strange reason the constructor method
implementing publishActivity in PHP using the REST API using this code: $activity = array(
Implementing a custom membership provider, there are certain properties such as MinRequiredPasswordLength that only
Every security systems have its limits. I understand that hardware key logger cannot be
I'm looking at implementing some form of anonymous user system in Rails. I need
Is there a framework that supports UnitTesting of WPF applications. It should not be
I'm implementing a logger as an aspect using Spring AOP and Log4J, but I've
I wonder what the best approach is in implementing a logger which essentially eats
i was wondering if the following scheme of action is possible: i am implementing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.