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
    May 3, 2021 at 11:38
  • Hi Anand, Thank you for your quick response, Yes I am using Topology setup 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 May 3, 2021 at 13:43
  • Happy it worked .You used the razor template.
    – Anand N S
    May 3, 2021 at 13:48
  • Yes using razor mediator template May 8, 2021 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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