在RedirectToAction之后,路由表中的路由不匹配提供的值

时间:2014-02-21 07:00:38

标签: c# asp.net-mvc asp.net-routing

我有下一个路线设置:

routes.MapRoute(
                    name: "TestCC",
                    url: "TestCC/{action}",
                    defaults: new { controller = "PaymentHub", action = "Cancelled" }
                    );

  routes.MapRoute(
                    name: "Default",
                    url: "{culture}/{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                    );

当用户打开TestCC操作时,我会尝试将它们重定向到应该跟踪{culture}的其他操作

public ActionResult TestAction()
        {
            TempData["pp"] = Request["p1"];
            TempData["dd"] = Request["p2"] ;
            return RedirectToAction("OtherAction", "OtherController");
        }

如何在RedirectToAction中添加{culture}部分以重定向? 我不想将culture =“value”写入默认路由。

1 个答案:

答案 0 :(得分:1)

不确定我是否理解正确,但我想这会做你想要的:

RedirectToAction("OtherAction", "OtherController", new {culture = "value"});