title: Removing session variable in view
body: <p>Why am I getting no output from this code if bellow it I add <code>@{ Session.Remove("errors"); }</code></p>
  
  <pre><code>            @if (Session["errors"] != null)
              {
  
                  &lt;div class="alert alert-danger"&gt;
                      &lt;ul&gt;
                          @{
                              String[] errors = (String[])Session["errors"];
                          }
                          @foreach (String error in errors)
                          {
                              &lt;li&gt;@error&lt;/li&gt;
                          }
                      &lt;/ul&gt;
                  &lt;/div&gt;
              }
  
              @if (Session["success"] != null)
              {
                  &lt;div class="alert alert-success"&gt;
                      @Session["success"]
                  &lt;/div&gt;
              }
  </code></pre>
  
  <p>Does code first get evaluated and then outputted but even then it makes no sense. Without <code>@{ Session.Remove("errors"); }</code> I get the output with it nothing it's very annoying.  </p>
  
  <p>Trying to do FLASH messages that persist for only the current request.</p>
  
  <p>Updated:  </p>
  
  <pre><code>        TempData["errors"] = new String[] { "You need to be logged in to access this page." };
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>        @if (TempData.ContainsKey("errors"))
          {
  
              &lt;div class="alert alert-danger"&gt;
                  &lt;ul&gt;
                      @{
                          String[] errors = (String[])TempData["errors"];
                      }
                      @foreach (String error in errors)
                      {
                          &lt;li&gt;@error&lt;/li&gt;
                      }
                  &lt;/ul&gt;
              &lt;/div&gt;
          }
  
          @if (TempData.ContainsKey("success"))
          {
              &lt;div class="alert alert-success"&gt;
                  @TempData["success"]
              &lt;/div&gt;
          }
  </code></pre>