title: ASP.NET MVC: Razor - How to keep nicely indented code without sending a load of white space to the browser
body: <p>I am using razor to render out javascript objects, as shown in the following code snippet</p>
  
  <pre><code>@{
      bool isFirst = true;
      foreach (var qa in Model.Form.FormItems)
      {
          if (isFirst)
          {
              isFirst = false;
          }
          else
          {
              @:,
          }
  
          @:new QuestionAndAnswer(
                  @:@(qa.QuestionAnswerId), 
                  @:@(qa.OrderNumber), 
                  @:@(qa.ParentOrderNumber), 
                  @:@(qa.IsHeader.ToJsonValue()),
                  @:@(qa.IsMandatory.ToJsonValue()),
                  @:@(qa.IsAlertable.ToJsonValue()),
                  @:@(qa.IsAlarmable.ToJsonValue()),
                  @:@(qa.IsKeyItem.ToJsonValue()),
                  @:@(qa.IsHiddenQuestion.ToJsonValue()),
                  @:new Question(
                      @:@(qa.Question.QuestionId), 
                      @:@Html.Raw(qa.Question.IdCode.ToJsonValue()),
                      @:new OverridableFormItemText(
                          @:@(qa.Question.ItemText.DefaultFormItemTextId),
                          @:@Html.Raw(qa.Question.ItemText.DefaultText.ToJsonValue()),
                          @:@Html.Raw(qa.Question.ItemText.DefaultHelpText.ToJsonValue()),
  ..etc...
  </code></pre>
  
  <p>This makes my cshtml pages easy to read and well laid out. </p>
  
  <p>Unfortunately, all the indents are rendered to the browser make the page around 4x bigger than it need to be. Example snippet of the html:</p>
  
  <pre><code>new QuestionAndAnswer(
      34500, 
      2, 
      1, 
      false,
      false,
      false,
      false,
      false,
      false,
      new Question(
          33955, 
          "123",
          new OverridableFormItemText(
              23879,
              "Locality",
              "",
              null,
              "",
              ""
          )
      ),
          new Answer(
              22196,
              "321",
              4,
              "MultipleChoiceSingleSelect",
  </code></pre>
  
  <p>Is there are way for me to retain the nicely formatted server side code but send a unformatted version (ie. no indents) to the browser that saves on bandwidth?</p>