0

I am trying to make this code work by checking if there is a movie id in the link so it will render different text than if there is no id

@if (Model.Movie.Id != null)

enter image description here

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Edit316
  • 1
  • 1

1 Answers1

1

Your Model.Movie object must be null in some cases, attempting to check a property of a null value will throw that error.

You could try doing this instead so you check Movie and THEN check the id:

@if (Model.Movie != null && Model.Movie.Id != null)
Alejandro
  • 413
  • 3
  • 9