Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Here is my code:
public class RedirectionPageController : RenderMvcController
public ActionResult Index(RenderModel model)
var child = model.Content.FirstChild();
var viewName = child.GetTemplateAlias();
return new HttpStatusCodeResult(HttpStatusCode.NotFound);
return View(viewName, child);
I want to render view of first child of that page, but if it have no template - render the 404 page. But builtin Umbraco 404-handling behavior does't executed in case. All the others pages (without hijacking) without views (templates) working well with builtin 404-handling.
How to make Umbraco force it own 404 handling?
I think you need to use the IContentFinder instead if you want the default 404-handling to be in effect.
I made a quick example for you tested with Umbraco 8:
public class MyApplication : IUserComposer
public void Compose(Composition composition)
public class RedirectionContentFinder : ContentFinderByUrl
public RedirectionContentFinder(ILogger logger) : base(logger)
public override bool TryFindContent(PublishedRequest request)
bool result = base.TryFindContent(request);
if (request.PublishedContent != null && request.PublishedContent.ContentType.Alias.Equals("redirectionPage", StringComparison.InvariantCultureIgnoreCase))
var firstChild = request.PublishedContent.Children.FirstOrDefault();
var firstChildTemplateAlias = firstChild?.GetTemplateAlias();
request.PublishedContent = null;
request.Is404 = true;
request.PublishedContent = firstChild;
For Umbraco 7 you should replace IUserComposer with IApplicationEventHandler and put the code in ApplicationStarting
A good solution, but not what I need.
I don't want to make my own ContentFinder, I need to use the builtin implementation of it.
Are there any other approaches for?
I think I have to get ContentFinder collection and find LastChanceContentFinder or something like that.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted