Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Update for Umbraco 7
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Web.Routing;
namespace FEE.Domain.MemberProfile
// From
public class MemberProfileContentFinder : IContentFinder
public bool TryFindContent(PublishedContentRequest contentRequest)
var urlParts = contentRequest.Uri.GetAbsolutePathDecoded()
.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
//Check if the Url Parts
// Starts with /profile/*
if (urlParts.Length > 1 && urlParts[0].ToLower() == "profile")
//Lets try & find the member
var memberName = urlParts[1];
//Try and find a member where the property matches the memberName
List<IMember> tryFindMember =
if (!tryFindMember.Any()) // try a partial match just in case
tryFindMember = ApplicationContext.Current.Services.MemberService.GetMembersByPropertyValue("umbracoUrlName",
//See if tryFindMember is not null
if (tryFindMember.Any())
//Need to set the member ID or pass member object to published content
HttpContext.Current.Items["memberProfile"] = tryFindMember.FirstOrDefault();
//Set the Published Content Node to be the /Profile node - can get properties off it & my member profile in the view
contentRequest.PublishedContent =
//Return true to say found something & stop pipeline & other contentFinder's from running
return true;
//Not found any content node to display/match - so run next ContentFinder in Pipeline
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment