本文介绍了在@model和@inherit鉴于头MVC4剃刀区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要做出一个视图强类型,我们可以使用 @model @inherit 。能否请你指导我什么是他们两个人的差异。我新来的MVC,无法弄明白。

To make a view strongly typed we can use @model and @inherit. Can you please guide me what is difference in both of them. I m new to MVC and couldn't figure it out.

请指导。

编辑:

请参见下面的例子:http://www.arrangeactassert.com/asp-net-mvc-razor-view-best-practices-keep-logic-out-of-your-razor-views/

推荐答案

所不同的是:如果你的视图继承了 WebViewPage< T> 然后你的模型指导点以 T

The difference is as follows: if your view inherits from WebViewPage<T> then your model directive points to T.

在换言之,这两个是相同的

In other words, these two are equivalent

@inherits System.Web.Mvc.WebViewPage<ModelClass>

@model ModelClass

参考:http://weblogs.asp.net/scottgu/archive/2010/10/19/asp-net-mvc-3-new-model-directive-support-in-razor.aspx

这篇关于在@model和@inherit鉴于头MVC4剃刀区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 06:46
查看更多