Redirect to Action from within a method

Viewed 2225

In most of the Actions in my controller I need to check to see if a condition has been meet, and if not redirect the user to another Action in the same controller so I tried:

    public ActionResult Transactions()
    {
        GrossGalsConfermation();
        return View();
    }

    public void GrossGalsConfermation()
    {
        if (Session["HasConfirmed"] == null && TerminalUserData.IsGrossGallonTerminal)
        {
            RedirectToAction("ConversionFactors");
        }
    }

but even when the if statement is true the RedirectToAction is not executed. I have done a debug in VS and can see it jump from the Action to the Method, evaluate the IF statement and go into it to run the RedirectToAction but then it jumps right back to the calling Acation and return's it's view. How can I force it to redirect? Searching on line I find similar problems and the solution was to change from void to ActionResult but then I have to provide an fallback Action to return which can not be done since this Method will be called by dozens of views.

3 Answers
Related