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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:33:48+00:00 2026-06-04T04:33:48+00:00

If I define an Action filter that implements IActionFilter like so: public class FooAttribute

  • 0

If I define an Action filter that implements IActionFilter like so:

public class FooAttribute : FilterAttribute, IActionFilter
{
    public void OnActionExecuted(ActionExecutedContext filterContext)
    { }

    public void OnActionExecuting(ActionExecutingContext filterContext)
    {
        filterContext.Result = new ContentResult 
        { 
            Content = "Test", 
            ContentEncoding = Encoding.UTF8, 
            ContentType = "text" 
        };
    }
}

And apply it to the following action method:

[Foo]
public ActionResult Index()
{
    return View();
}

When I do this the Index action code does not run and neither does the OnResultExecuted method. Is this because I set the Result property in the OnActionExecuting method? Are there any other things that will cause the normal flow to be interrupted?

  • 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-04T04:33:49+00:00Added an answer on June 4, 2026 at 4:33 am

    I think its just the Result property that has this effect..
    See here : http://books.google.be/books?id=gzfFQrs_qQAC&lpg=PA442&ots=EXCefpt5-O&dq=iactionfilter%20onactionexecuting&pg=PA442#v=onepage&q=iactionfilter%20onactionexecuting&f=false

    User can cancel the action by setting Result to something non-null

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

Sidebar

Related Questions

Is it possible to create a global action filter that will automatically apply to
I have the following actionfilter: public class PopulateMetaAttribute : ActionFilterAttribute { public override void
I'm trying to define an action for a model Bar -- but I only
I can do request.path_parameters['controller'] and request.path_parameters['action'], but is there anything like request.path_parameters['template'] so I
I'm trying to use a class as a before filter for multiple controllers. Because
Sometimes my application generates URLs that look like http://localhost/?Area= or http://localhost/SomeController?Area= I don't currently
Basics uses this phrase to define/describe Shapes : ...object that contains all the information...
So I don't apply an authenticate filter to my index action, but non-logged in
I'm building a custom authentication filter class in Grails. It's working, but it bugs
I would like to define an after_filter to restore the changes of my before_filter

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.