I am trying to read PublicationTarget Title as explained in the following link https://www.curlette.com/?p=1038

using below code snippet

var engine = TridionHelper.Engine;
var publishContext = engine.PublishingContext;
var pubTargetTitle = publishContext.PublicationTarget.Title;

But I am getting null exception as I am getting PublicationTarget null. We are using SDL Web 8.5

Can you please help me to troubleshoot the issue?

  • Prasanna , Are you using Topology setup for publishing target or you using Legecy Publishing Target.
    – Anand N S
    Commented May 3, 2021 at 11:38
  • Hi Anand, Thank you for your quick response, Yes I am using Topology setup Commented May 3, 2021 at 12:50

1 Answer 1


publishContext.PublicationTarget.Title; is not working with razor , you can use Engine.PublishingContext.TargetType and see if you can get the target , if not create a .net Code and use it on your Component Template

refer to this link for mofre details.

  • Thank you Anand, It worked To read Title we need to use Engine.PublishingContext.TargetType.Title Commented May 3, 2021 at 13:43
  • Happy it worked .You used the razor template.
    – Anand N S
    Commented May 3, 2021 at 13:48
  • Yes using razor mediator template Commented May 8, 2021 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.