从MVC控制器重定向到另一个episerver页面?

And*_*wVA 5 asp.net-mvc episerver

如何从Episerver中的任何MVC控制器重定向到任何页面(例如Home)?例如,登录后 - 重定向到起始页面.

Tho*_*ntz 10

要重定向到任何MVC操作:

public ActionResult Index()
{
    return RedirectToAction("Index", "Home");
}
Run Code Online (Sandbox Code Playgroud)

重定向到站点的已配置起始页:

public ActionResult Index()
{
    PageData startPage =
        ServiceLocator.Current.GetInstance<IContentRepository>().Get<PageData>(ContentReference.StartPage);

    // get URL of the start page
    string startPageUrl = ServiceLocator.Current.GetInstance<UrlResolver>()
                .GetVirtualPath(startPage.ContentLink, startPage.LanguageBranch);

    return Redirect(startPageUrl);
}
Run Code Online (Sandbox Code Playgroud)


aol*_*lde 10

实际上,只要您还提供页面的内容引用,您仍然可以将RedirectToAction与EPiServer一起使用.

public ActionResult Index()
{
    return RedirectToAction("ActionName", new { node = ContentReference.StartPage });
}
Run Code Online (Sandbox Code Playgroud)

这已经在EPiServer 7.5.440.0中进行了测试.