MVC4 Razor difference in @model and @inherit in view header?

前端 未结 2 591
孤独总比滥情好
孤独总比滥情好 2021-01-01 15:09

To make a view strongly typed we can use @model and @inherit. Can you please tell me what the difference is between both of them?

Edit:

2条回答
  •  长发绾君心
    2021-01-01 15:51

    They are the same (i.e. indicate strongly-typed model classes) but @inherit is more verbose (because of the full path). @inherit was the only way to do it when razor was first introduced (pre-release of MVC 3 I think), but I haven't seen it used for years.

提交回复
热议问题