I have a front page and a CMS area with the following routes:

Default Front Page route

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

Administration route

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

I would like to route from my ContentController (inside the administration area) to the front page HomeController, like this:

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

How can i do this?

有帮助吗?

解决方案

just return RidirectToAction("Index", "Home");

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top