title: Mixing C# and HTML Helper tags ASP.NET MVC 6 (ASP.NET Core)
body: <p>I'm using the new Helper tags in ASP.NET MVC 6.</p>
  
  <pre><code>    &lt;form asp-area="DAS"
            asp-controller="Report"
            asp-action="Add"
            asp-route-id="@Model.id"
            asp-route-incBalance="@Model.incBalance"
            asp-route-dateSet="@Model.dataStart.ToString("yyyy-MM-dd")"
            asp-route-dateNext="@Model.dataEnd.ToString("yyyy-MM-dd")"
            method="post" role="form"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I want to routing attribute:</p>
  
  <pre><code>asp-route-dateNext="@Model.dataEnd.ToString("yyyy-MM-dd")"
  </code></pre>
  
  <p>was applied only if:</p>
  
  <pre><code>          {
                if (Model.incBalance == 0)
                {
                    asp-route-dateNext="@Model.dataEnd.ToString("yyyy-MM-dd")"
                }
            }
  </code></pre>
  
  <p>As a result, I want to get something like this:</p>
  
  <pre><code>    &lt;form asp-area="DAS"
            asp-controller="Report"
            asp-action="Add"
            asp-route-id="@Model.id"
            asp-route-incBalance="@Model.incBalance"
            asp-route-dateSet="@Model.dataStart.ToString("yyyy-MM-dd")"
            {
               if (Model.incBalance == 0)
               {
                   asp-route-dateNext="@Model.dataEnd.ToString("yyyy-MM-dd")"
               }
            }
            method="post" role="form"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I get these errors:</p>
  
  <blockquote>
    <p>TagHelper attributes must be well-formed.</p>
  
  <pre><code>          if (Model.incBalance == 0)
  </code></pre>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>The tag helper 'form' must not have C# in the element's attribute
    declaration area.</p>
  
  <pre><code>              asp-route-dateNext="@Model.dataEnd.ToString("yyyy-MM-dd")"
  </code></pre>
  </blockquote>
  
  <p>I'm using Visual Studio 2015 Update 1</p>
  
  <p><strong>Update 1:</strong>
  I also tried this option:</p>
  
  <pre><code>@(Model.incBalance == 0 ? "asp-route-dateNext=" + Model.dataEnd.ToString("yyyy-MM-dd") : string.Empty)
  </code></pre>
  
  <p>But the error remained:</p>
  
  <blockquote>
    <p>The tag helper 'form' must not have C# in the element's attribute
    declaration area.</p>
  
  <pre><code>      @(Model.incBalance == 0 ? "asp-route-dateNext=" + Model.dataEnd.ToString("yyyy-MM-dd") : string.Empty)
  </code></pre>
  </blockquote>