【问题标题】:How to route from a area to the default route如何从一个区域路由到默认路由
【发布时间】:2013-07-17 06:03:51
【问题描述】:

我有一个首页和一个 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");
}

我该怎么做?

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2016-12-26
      • 2013-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-09
      • 2013-06-17
      相关资源
      最近更新 更多