How to display a list of objects in an MVC View?

后端 未结 2 1550
攒了一身酷
攒了一身酷 2021-01-13 07:17

I have a method that is returning a list of strings. I simply would like to display that list in a view as plain text.

Here\'s the list from the controller:<

2条回答
  •  暖寄归人
    2021-01-13 08:07

    You can do it as follows in the view,

    @foreach (var item in @Model)      
    {      
         
  • @item.PropertName
  • }

提交回复
热议问题