could anyone please tell me why am I getting null reference error when creating new element using Razor Pages. New item is being created using proper (selected) values, list is visible, but after sending post request it just crashes.
I am using tag helpers:
<select asp-for="@Model.Book.AuthorId" asp-items="@(new SelectList(Model.AuthorsList, "AuthorId", "AuthorName"))"></select>
ViewModel looks like this:
public class BookCreateViewModel
{
public Book Book { get; set; }
public IEnumerable<Author> AuthorsList { get; set; }
}
Yes, the idea is to create new book using previously created authors.