title: What kind of code-optimizations in Views Razor does, if any?
body: <p>I met the following code:</p>
  
  <pre><code>@if (!String.IsNullOrWhiteSpace(@Html.Action("FlyoutShoppingCart", "ShoppingCart").ToString()))
  {
     //...
     &lt;ul class="dropdown-menu"&gt;
         &lt;li&gt;@Html.Action("FlyoutShoppingCart", "ShoppingCart")&lt;/li&gt;
     &lt;/ul&gt;   
  }
  </code></pre>
  
  <p>that makes @Html.Action("FlyoutShoppingCart", "ShoppingCart") to be executed twice, I fixed code introducing variable:</p>
  
  <pre><code>var shoppingCartHtml = @Html.Action("FlyoutShoppingCart", "ShoppingCart").ToString()
  if(!string.IsNullOrEmpty(shoppingCartHtml))
  {  //...
     &lt;ul class="dropdown-menu"&gt;
         &lt;li&gt;@shoppingCartHtml&lt;/li&gt;
     &lt;/ul&gt;
  }
  </code></pre>
  
  <p>but still have some questions about code optimizations: </p>
  
  <blockquote>
    <ol>
    <li>Does Razor do any code-optmizations in Views?</li>
    <li>When C# code in views is dynamically compiled and translated to MSIL, the dynamic compilation does same optimizations as C# compiler
    does building dll?</li>
    <li>Could such things as in example above be optimized, by CLR/JIT compilers?</li>
    </ol>
  </blockquote>