title: How does one avoid a NullReferenceException in a foreach loop within a View when my model is null?
body: <p>I get a "NullReferenceException was unhandled by user code" error with the following code in my View when I pass in a null value via my controller.  There are situations where I want to pass in a null value, but I do not want an error thrown when this happens.  What should I change my code to?</p>
  
  <p>Originally my code was:</p>
  
  <pre><code>@foreach (var item in Model.MyModelStuff)
  {
      &lt;tr&gt;
          &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Bla.Title)
          &lt;/td&gt;
      &lt;tr&gt;
  }
  </code></pre>
  
  <p>I have tried the following with no success:</p>
  
  <pre><code>@foreach (var item in Model.MyModelStuff.Where( item =&gt; item.MyModelStuff != null))
  etc. . . 
  </code></pre>
  
  <p>How do I change the code so that it will handle null without throwing an error?  I've read I may need to be returning an empty collection of my model (?), how would I go about doing that - if it is indeed the necessary thing to do?</p>