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中进行了测试.
| 归档时间: |
|
| 查看次数: |
5494 次 |
| 最近记录: |