C#C
C#4y ago
6 replies
Marcoelho97

❔ System.NullReferenceException 'Object reference not set to an instance of an object.'

Hello!
I'm getting a little desperate here:
This is my index code:
public IActionResult Index()
        {
            // List<Tipo> list = _context.Tipos.ToList();
            List<string> list = new List<string>();
            list.Add("Home");
            list.Add("Home");
            list.Add("Home");
            list.Add("Home");
            return View(list);
        }

This is my index.cshtml:
<select class="form-select" name="tipo" id="tipo">
            @foreach (var item in Model)
            {
                <option value="abc">abc</option>
            }
        </select>

Why do I get this exception? I've been at it for over an hour, I'm new at this, and I'm very confused
Was this page helpful?