C
Join ServerC#
help
❔ System.NullReferenceException 'Object reference not set to an instance of an object.'
MMarcoelho9712/16/2022
Hello!
I'm getting a little desperate here:
This is my index code:
This is my index.cshtml:
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
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
DDeluxe12/16/2022
where is the exception occuring
MMarcoelho9712/16/2022
At the Foreach, the "Model" part
DDeluxe12/16/2022
is this happening when the page first loads, or after you try to submit a form or something? As is, it seems fine
MMarcoelho9712/16/2022
When I try to run the app
MMarcoelho9712/16/2022
._.' Closed the project, re-opened and my HomeController had gone to its initial state
Tried doing the exact same thing, it's now working, for some reason :|
Tried doing the exact same thing, it's now working, for some reason :|
AAccord12/17/2022
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.