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

  • Home
  • SEARCH
  • 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 8517259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:38:55+00:00 2026-06-11T05:38:55+00:00

I wrote a action filter which is similar to a log function : public

  • 0

I wrote a action filter which is similar to a log function :

public class TrackActionFilterAttribute : ActionFilterAttribute, IActionFilter
{
   public override void OnActionExecuting(ActionExecutingContext filterContext)
   {
      Tracking track = new Tracking()
      {
        Action = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName + filterContext.ActionDescriptor.ActionName
      };
      context.Trackings.Add(track);
      context.SaveChanges();
   }
}

and I have action methods like this :

[TrackActionFilter]
public ActionResult Index() 
{
  if (Request.Form["registered"] == 1) 
     return PartialView("Landing");
  else 
     return PartialView("Register");
}

[TrackActionFilter]
public ActionResult Landing() 
{
   return PartialView();
}

[TrackActionFilter]
public ActionResult Register()
{ 
   return PartialView();
}

My problem is when the Index action gets called, I am only registering the Index Action into the database. Since navigating to Index will result in either the Landing or Register Partial View, is there anyway to get these actions in any type of action filters?

The main reason is because i also want to track these actions inside my database and I cannot seem to do that. I’ve tried ActionExecuted , ResultExecuted to no avail. Would be glad if any experts could help!

  • 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-11T05:38:56+00:00Added an answer on June 11, 2026 at 5:38 am

    You have access request parameters in your action filter:

    filterContext.HttpContext.Request["registered"]
    

    and if you want to know which partial view was returned you have to use OnActionExecuted event because this event runs after the controller action has finished:

    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        var viewResult = filterContext.Result as ViewResultBase;
        if (viewResult != null)
        {
            // the controller action returned either a View or a partialView
            // => we could get its name:
            var name = viewResult.ViewName;
        }
    
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an action filter which i got from the below link http://blog.wekeroad.com/blog/aspnet-mvc-securing-your-controller-actions/ there
assuming i have a filter (which is being invoked before every action), how can
I am trying to unit test an action filter I wrote. I want to
I'm trying to log the actions made by a service I wrote using the
C# has anonymous delegates. So I can write: public vois foo(string d, Action t){
I want to write a before_filter in my controller to identify the action which
i wrote a jquery function and now i want to use it as a
I have an action for searching in NSMutableArray with name searcharray, which is equal
I wanted to start a service from a Broadcast reciever which takes android.intent.action.BOOT_COMPLETED. When
Question: I want to implement a sessionAccess class, which throws a SessionExpired-Exception when an

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.