title: C# Passing an object into a ViewComponent using a TagHelper
body: <p>I'm trying to create a <code>ViewComponent</code> that I can use with TagHelpers where I pass in an object as the parameter.</p>
  
  <p>So, for example, I have this <code>ViewComponent</code>—which could end up having more parameters:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public IViewComponentResult Invoke(string? pageTitle, string? description, string? headerView)
  </code></pre>
  
  <p>And I'd like to do something like:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class PageHeaderViewComponentOptions 
  {
      public string pageTitle2;
      public string Description;
  }
  
  public IViewComponentResult Invoke(PageHeaderViewComponentOptions phvc)
  </code></pre>
  
  <p>And use it like:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;vc:page-header phvc:page-title2="Test Title"&gt;&lt;/vc:page-header&gt;
  </code></pre>
  
  <p>But, this isn't working. </p>
  
  <p>I also tried explicitly setting the attribute information on the parameter class as follows:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[HtmlTargetElement("PageHeaderViewController")]
  public class PageHeaderViewComponentOptions
  {
      [HtmlAttributeName("page-title")]
      public string pageTitle2 { get; set; }
      public string Description;
  }
  </code></pre>
  
  <p>With no luck either.</p>
  
  <p>My thought is that I could pass that object directly to the view. Typing this, I wonder if passing in the parameters separately and then assigning each to a member of a specific view model might be a better idea.</p>
  
  <p>Any help here would be greatly appreciated.</p>