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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:45:07+00:00 2026-06-10T06:45:07+00:00

On OnActionExecuting for a controller, I’m trying to do a permanent redirect. The code

  • 0

On OnActionExecuting for a controller, I’m trying to do a permanent redirect. The code looks like this:

protected override void OnActionExecuting(ActionExecutingContext filterContext) {
  var resolvedUrl = "http://www.cnn.com";
  filterContext.Result = new RedirectResult(resolvedUrl);
  filterContext.Result.ExecuteResult(filterContext);
  return;
}

It’s not immediately redirecting because this method is in a base class, and after the return statement, the inherited class’s OnActionExecuting method is called.

Question: how do I do the redirect and stop there, and not do anything in the inherited class. Thanks.

Note: in the child class (one that’s inheriting from base), I have base.OnActionExecuting(filterContext); in its OnActionExecuting.

  • 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-10T06:45:08+00:00Added an answer on June 10, 2026 at 6:45 am

    You shouldn’t call ExecuteResult() from within an action filter. Setting filterContext.Result to a non-null value is sufficient to prevent the MVC pipeline from invoking further filters.

    The subclassed type should instead be changed to read:

    base.OnActionExecuting(filterContext);
    if (filterContext.Result != null) {
      return; // something got short-circuited
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller that overrides OnActionExecuting and does something like this: protected override
public abstract class MyControllerBase : Controller { protected override void OnActionExecuting(ActionExecutingContext context) { //
I have the following: public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (filterContext ==
I have this ActionFilter public class AppOfflineFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext
My URLs look like: www.example.com/{languagecode}/{controller}/{action}/{id} where language code is en-us, etc. From the OnActionExecuting
This discussion suggests using a base controller and overriding OnActionExecuting . This one mentions
I have a controller that handles file uploads. Ultimately I would like to be
I have made a base controller class that overrides OnActionExecuting as follows: public class
On my controller I have it inherit a MainController and there I override the
I want to set up a ASP.NET MVC route that looks like: routes.MapRoute( Default,

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.