문제

My code :

 @if (Model.ClientTypes != null)
 {
  foreach (var clientType in Model.ClientTypes)
  {
     @:blabla :)
  }
 }

ClientTypes collection is a list and it´s not null, there are 5 elements in ClientTypes, razor engine enters in loop and after looping all 4 elements at the end throws null exception :(

what is wrong ?

enter image description here

올바른 솔루션이 없습니다

다른 팁

I ran into this same problem and discovered that the error was actually lying to me. The error wasn't on the foreach loop, it was on the line following the foreach loop. So my recommendation is to comment out anything that could be null immediately following the foreach loop and then uncomment one at a time until you find the culprit. Good luck!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top