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 8107469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:46:59+00:00 2026-06-06T00:46:59+00:00

How would you go about invoking the ActionFilterAttribute when you are calling a controllers

  • 0

How would you go about invoking the ActionFilterAttribute when you are calling a controllers method directly? Imagine the following:

public class ApiController : Controller {

    public ActionResult CallSomething() {
         return IsCalled();
    }

    [MyAction]
    public ActionResult IsCalled() {
         return View();
    }
}

So the request comes into /Api/CallSomething, the CallSomething() method internally calls another method (in this case IsCalled()) but when that method is called the ActionFilterAttribute is invoked and runs.

At the moment the ActionFilterAttribute will only be invoked if it’s part of the original request, which makes sense because then it’s part of the whole MVC lifecycle and all I’m doing is just calling a method directly, I’d need to do a RedirectToAction if I wanted it to get fired by MVC. RedirectToAction alters the URL so this isn’t suitable for my purposes.

I’ve poked about the System.Web.Mvc code but I can’t see how or when its being invoked. I figure that if it can do it then so can I potentially using reflection. In this event the Views aren’t relevant as I am override the ExecuteResult() to write my own content into the http response.

Anyway I’ve resigned myself to this maybe not being possible but I’d just thought it would be worth a try.

  • 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-06T00:47:01+00:00Added an answer on June 6, 2026 at 12:47 am

    There is no practically correct way to achieve that. So don’t attempt to do it. Controller actions shouldn’t be calling themselves as in your example. Use a redirect in this case. Or have the client send the request directly to the second action if you don’t want the redirect.

    Oh and if you have some common functionality between those controller actions that you want to reuse, simply externalize this functionality into some other layer. There are many ways to provide common functionality in ASP.NET MVC 3 depending on the exact scenario.

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

Sidebar

Related Questions

Any ideas how I would go about writing a javascript method to insert an
I'm wondering how i would go about making the following application: a user signs
I would like to ask about the button and the url post method in
I would like 'about' to route to 'abouts/1' I tried this: match 'about' =>
Just a quick question about how you would go about implementing this. I want
I would like to know how I would go about altering the HTML that
I was wondering how one would go about developing a website from scratch with
Anyone have any idea how I would go about converting a timestamp in milliseconds
Does anyone know how I would go about changing (transforming) an image based on
I am wondering how I would go about performing a certain function if a

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.