如何从区域路由到默认路由

时间:2013-07-17 06:03:52

标签: asp.net asp.net-mvc-4 routing asp.net-mvc-areas asp.net-routing

我有一个首页和一个CMS区域,其中包含以下路线:

默认首页路线

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    namespaces: new string[] { "SiteFactory.Site.Controllers" }

管理路线

context.MapRoute(
        "Administration_default",
        "administration/{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

我想从我的ContentController(在管理区域内)路由到首页HomeController,如下所示:

[HttpPost]
[ValidateInput(false)]
public ActionResult Save(string content, string contentId, string pageId)
{
    if (ModelState.IsValid)
    {
        //TODO: save content.
    }
    return RedirectToRoute("Default");
}

我该怎么做?

1 个答案:

答案 0 :(得分:1)

只是return RidirectToAction("Index", "Home");