Set the layout of the main page (i.e. the one you want to redirect from) to be an ashx generic handler. That would mean there is not UI code involved in any way.
You can do it with a lot less code, as long as the following assumptions are true:
1. All child items are newsletters
2. The latest is at the top (e.g. items are sorted by release date)
namespace YourSite
{
public class NewsletterHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Item item = Sitecore.Context.Item.Children[0];
string url = Sitecore.Links.LinkManager.GetItemUrl(item);
context.Response.Redirect(url);
}
public bool IsReusable { get { return false; } }
}
}
If the assumptions above are wrong, finding the latest published may not be as simple as getting the publish date as described by Zooking. It may be, but if you make a fix to an older newsletter and re-publish, that code may fail (i think?). If it's fine, no problem, Zooking is correct, otherwise you may want to actual give each newsletter a specific date field .. in that case, use the code here in your handler.
namespace YourSite
{
public class NewsletterHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Item[] children = Sitecore.Context.Item.Axes.GetDescendants();
Item item = children.AsQueryable()
.Where(c => c.TemplateName.ToLower()
.Contains("newsletter"))
.OrderByDescending(c => DateTime.Parse(c["PublishDate"])).FirstOrDefault();
string url = Sitecore.Links.LinkManager.GetItemUrl(item);
context.Response.Redirect(url);
}
public bool IsReusable { get { return false; } }
}
}