<commit_before>﻿namespace System.Web.Mvc.Expressions
{
    using System;
    using System.Linq.Expressions;
    using System.Web.Mvc;
    using System.Web.Routing;

    public static class ControllerExtensions
    {
        public static RedirectToRouteResult RedirectToAction<TController>(this TController controller, Expression<Action<TController>> action, object routeValues = null)
            where TController : Controller
        {
            var routeValuesDict = new RouteValueDictionary(routeValues);
            routeValuesDict.AddRoutesFromExpression(action);

            return new RedirectToRouteResult(routeValuesDict);
        }
    }
}<commit_msg>Added option to redirect to different controller<commit_after>﻿namespace System.Web.Mvc.Expressions
{
    using System;
    using System.Linq.Expressions;
    using System.Web.Mvc;
    using System.Web.Routing;

    public static class ControllerExtensions
    {
        public static RedirectToRouteResult RedirectToAction<TController>(this TController controller, Expression<Action<TController>> action, object routeValues = null)
            where TController : Controller
        {
            return GetRedirectFromExpression(action, routeValues);
        }

        public static RedirectToRouteResult RedirectToAction<TController, TRedirectController>(this TController controller, Expression<Action<TRedirectController>> action, object routeValues = null)
            where TController : Controller
            where TRedirectController : Controller
        {
            return GetRedirectFromExpression(action, routeValues);
        }

        private static RedirectToRouteResult GetRedirectFromExpression<TRedirectController>(Expression<Action<TRedirectController>> action, object routeValues = null)
            where TRedirectController : Controller
        {
            var routeValuesDict = new RouteValueDictionary(routeValues);
            routeValuesDict.AddRoutesFromExpression(action);

            return new RedirectToRouteResult(routeValuesDict);
        }
    }
}
{'fraction_non_alphanumeric': 0.06280428432327166, 'fraction_numerical': 0.0, 'mean_word_length': 3.3446088794926006, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5930034', 'n_tokens_mistral': 478, 'n_tokens_neox': 478, 'n_words': 113}