-3

In Visual Studio, this error occurs:

The object reference is not set to the instance of an object.

It gives the error on the foreach line. Why is this happening?

@foreach (var item in Model)
{
    <div class="kitap">

        <img src="~/Content/images/sucveceza.png">
        <p>@item.KonuBaslik</p>
        <a href="">

        </a>
        }

    </div>
}
Sᴀᴍ Onᴇᴌᴀ
  • 7,491
  • 8
  • 27
  • 56
  • 1
    Because `Model` is `null` (you did not pass a model to the view) –  Dec 17 '16 at 01:01
  • 5
    Possible duplicate of [What is a NullReferenceException, and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) –  Dec 17 '16 at 01:01

1 Answers1

0

There could be multiple reasons

  1. You have not passed model from controller.
  2. you passed model but value is null.