title: How can I inject ViewDataDictionary or ModelStateDictionary into TagHelper?
body: <p>In razor views I can access model state object:</p>
  
  <pre><code>@ViewData.ModelState
  </code></pre>
  
  <p>How can i inject and access <code>ViewData</code> or <code>ModelState</code> objects in razor <code>TagHelper</code>? I tried the following, however the <code>ViewData</code> and <code>ModelState</code> are always null:</p>
  
  <pre><code>public class ModelStateTagHelper : TagHelper
  {
      public ViewDataDictionary ViewData { get; set; }
      public ModelStateDictionary ModelState { get; set; }
  
      public override void Process(TagHelperContext context, TagHelperOutput output)
      {
      }
  }
  </code></pre>