All the credits go to @DavidG and @CodeCaster, mentioned in the comments.

@(((CustomPrincipal)Context.Items["IUser"]).Name)

The parentheses where required because otherwise there is no Name property on the Object type which is what Context.Items["IUser"] is. We have to add parentheses to cast that Object to CustomPrincipal first, then access the Name property of that type.