title: How share ViewData between ViewComponent in Asp.net core
body: <p>I have two ViewComponent and i want use ViewData or other technic for share some data between and then use this data in main view, but this is not the way, and ViewData per ViewComponent is null when rich to if condition for both ViewComponent.</p>
  
  <pre><code>public class OneViewComponent : ViewComponent
  {
      public async Task&lt;IViewComponentResult&gt; InvokeAsync(Page page, Zone zone)
      {
          //some operation
  
          string text = "one";
  
          if(ViewData["data"] != null)
          {
              ViewData["data"] = ViewData["data"].ToString() + text;
          }
          else
          {
              ViewData["data"] = text;
          }
  
          return View();
      }
  }
  
  public class TwoViewComponent : ViewComponent
  {
      public async Task&lt;IViewComponentResult&gt; InvokeAsync(Page page, Zone zone)
      {
          //some operation
  
          string text = "two";
  
          if(ViewData["data"] != null)
          {
              ViewData["data"] = ViewData["data"].ToString() + text;
          }
          else
          {
              ViewData["data"] = text;
          }
  
          return View();
      }
  }
  </code></pre>