title: Wix: Passing a property back from a C# custom action
body: <p>Is it possible to pass a property back from a WiX custom action? I've been trying to figure out a solution for hours now, I've seen many answers but none of them work for me. Here's what I tried,</p>
  
  <p><strong>C# (Custom Action)</strong></p>
  
  <pre><code>public class CustomActions
  {
      [CustomAction]
      public static ActionResult TestAction(Session session)
      {
          session["FOO"] = "BAR";
          return ActionResult.Success;
      }
  }
  </code></pre>
  
  <p><strong>WiX FooDlg.wxs</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
    &lt;Fragment&gt;
      &lt;Property Id="FOO"/&gt;
      &lt;UI&gt;
        &lt;Dialog Id="FooDlg" Width="370" Height="270" Title="Foo"&gt;
  
          &lt;Control Id="FOO" Type="Edit" Property="FOO" Height="17" Width="45" X="50" Y="150" Text="[FOO]" Indirect="no"/&gt;
  
          &lt;Control Id="FOO" Type="PushButton" X="150" Y="200" Width="56" Height="17" Text="Test FOO"&gt;
            &lt;Publish Event="DoAction" Value="Testing"&gt;1&lt;/Publish&gt;
          &lt;/Control&gt;
  
        &lt;/Dialog&gt;
      &lt;/UI&gt;
      &lt;CustomAction Id='FOO' BinaryKey='FooBinary' DllEntry='TestAction' Execute='immediate' Return='check'/&gt;
      &lt;Binary Id='FooBinary' SourceFile='FOO.dll'/&gt;
    &lt;/Fragment&gt;
  &lt;/Wix&gt;
  </code></pre>