title: C# - System.Web.HttpParseException error when having unclosed HTML elements inside an @if
body: <p>I have a simple HTML which changes depending of <code>topic.IsScheduled</code>'s value <em>(bool)</em>:</p>
  
  <h3>if false:</h3>
  
  <pre><code>+-------------------+-------------------+
  |     row-fluid                         |
  +-------------------+-------------------+
  | span6(something1) | span6(something2) |
  +-------------------+-------------------+
  </code></pre>
  
  <h3>if true:</h3>
  
  <pre><code>+-------------------+-------------------+
  |     row-fluid                         |
  +-------------------+-------------------+
  | span6(something1) | span6(something3) |
  +-------------------+-------------------+
  |     row-fluid                         |
  +-------------------+-------------------+
  | span6(something2) | span6(something4) |
  +-------------------+-------------------+
  </code></pre>
  
  <p>The razor/cshtml:</p>
  
  <pre><code>&lt;div class="row-fluid"&gt;
          &lt;div class="span6"&gt;
              something1
          &lt;/div&gt;
      @if (topic.IsScheduled){
          &lt;div class="span6"&gt;
              something3
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row-fluid"&gt;
      }
          &lt;div class="span6"&gt;
              something2
          &lt;/div&gt;
      @if (topic.IsScheduled) {
          &lt;div class="span6"&gt;
              something4
          &lt;/div&gt;
      }
  &lt;/div&gt;
  </code></pre>
  
  <p>But when I do this, I get the following error when running the project:</p>
  
  <pre><code>System.Web.HttpParseException (0x80004005): The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup. at 
  </code></pre>
  
  <p>I've tested and C# is giving me errors because <code>div</code>s aren't closed inside the <code>@if</code> statement, <em>not because of missing opening/closing brackets</em>. If I close them inside the if, or simply comment the entire if with <code>@* *@</code>, then it works.</p>
  
  <h3>How can I configure to ignore <code>HttpParse</code> or even turn it off so stops parsing my HTML?</h3>
  
  <p><em>Yes, I can make the if/else but then I'll have duplicated HTML and variables because parser is dumb, which I wanted to avoid.</em></p>