Skip to content

Instantly share code, notes, and snippets.

@leekelleher
Created August 24, 2011 15:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leekelleher/1168374 to your computer and use it in GitHub Desktop.
Save leekelleher/1168374 to your computer and use it in GitHub Desktop.
Umbraco template to redirect the current page/node to its first child page/node.
<%@ Master Language="C#" MasterPageFile="~/masterpages/BlankTemplate.master" AutoEventWireup="true" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
var current = umbraco.NodeFactory.Node.GetCurrent();
if (current != null)
{
var child = current.ChildrenAsList.FirstOrDefault();
if (child != null)
{
var url = child.Url;
if (!string.IsNullOrEmpty(url))
{
Response.Redirect(url, true);
return;
}
}
}
Response.Redirect("/", true);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment