title: Event System Error with Tridion UI (Experience Manager)
body: <p>We are publishing extra page using event system on publishing event of pages. 
  It is working well when we publish a page from the CME. When we create a page using Tridion UI, it is created and published as expected but the event system throws error when it tries to create a target type object. </p>
  
  <pre><code> try
              {
                  foreach (var t in e.Targets)
                  {
                      var targets = new List&lt;TargetType&gt;();
  
                     some logic
  
                      targets.Add(new TargetType(t.Id, page.Session)); // error is in this line
  
                      PublishInstructionBase pib = e.PublishTransactions.First().Instruction;
                      PublishInstruction pi = new PublishInstruction(page.Session);
                      pi.StartAt = pib.StartAt;
                      pi.RollbackOnFailure = pib.RollbackOnFailure;
  
  
                      PublishEngine.Publish(
                          items,
                          pi,
                          targets,
                          PublishPriority.Low
                      );
                  }
  
              }
  </code></pre>
  
  <p>Exception we are getting is <strong>InvalidURIException</strong></p>
  
  <p>Both <strong>t and Session</strong> are not definitely not null which we verified by writing log over there. </p>
  
  <p>Please do suggest what we can to fix the issue?</p>
  
  <p>We manage to fix that by little hack putting code in try catch and creating target type manually if there is exception as we do know Tridion UI publish to staging only initially.</p>
  
  <p>Thanks,
  Vikas Kumar</p>