Object reference not set to an instance of an object - Partial View

前端 未结 2 1849
傲寒
傲寒 2020-12-22 09:05

I have a strongly typed partial view which is giving me \"Object reference not set to an instance of an object\" error when I launch the master view. I know I am not passing

2条回答
  •  醉梦人生
    2020-12-22 09:42

    If you need to render this partial view when you don't have a Model, you can certainly test that Model is not null before the foreach loop

    if (Model != null)
        foreach (...)
    

提交回复
热议问题