ASP.NET MVC或剃刀 [英] MVC ASP.NET or Razor

查看:141
本文介绍了ASP.NET MVC或剃刀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的MVC ...我有相当多的银 - 光与WPF和MVVM,但一知半解的知识的问候MVC。我在微软的网站<一个沿主以下教程href=\"http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-view\">http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-view.我相信我在第3条9.最初它告诉我要创造我的MVC站点使用剃刀的视图引擎。我选择使用ASPX而不是剃刀,因为我以为我会少第三方的依赖。

I'm very new to MVC...I have quite a bit of knowledge with Silver-light and WPF and MVVM but little knowledge in regards to MVC. I'm following along the main tutorial on Microsoft's site http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-view. I believe I'm on article 3 of 9. Originally it told me to create my MVC Site as using the "View Engine" of "Razor". I chose to use "ASPX" instead of "Razor" as I thought I would have less third party dependencies.

在开始一个新的MVC Web应用程序是它最好使用剃刀,而不是ASPX。说实话,我没有区别的想法。如前所述,我选择ASPX,以避免任何额外的第三方DLL或code。如果它是最好选择ASPX我有点困惑,为什么在MS的站点上的教程告诉我下手剃刀。

When starting a new MVC Web Application is it best to use "Razor" as opposed to "ASPX". To be honest I have no idea of the difference. As stated I chose ASPX to avoid any extra third party dlls or code. If it is best to choose ASPX I'm a bit confused as to why the tutorials on MS's site are telling me to start with Razor.

任何人都可以阐明一些轻的时候我应该使用,而不是在剃刀视图引擎的ASPX视图引擎?

Can anyone shed some light on to when I should use the "ASPX" view engine as opposed to the "Razor" view engine?

推荐答案

有是关于对第三方的依赖任何东西没有区别。 ASPX是好的,但剃须刀比较好,主要是因为它保持你的出路。

There is no difference regarding dependencies on 3rd party anything. ASPX is fine, but Razor is better, mostly because it stays out of your way.

您应该阅读斯科特Guthrie的博客文章介绍剃刀

You should read Scott Guthrie's blog post Introducing "Razor".

您基本上替换开始和结束标记&LT;%%&GT; @ 符号,至今较少的按键做同样的事情,即

You basically replace the opening and closing tags <% and %> with an @ symbol, so far fewer keystrokes to do the same thing, i.e.

&LT;%:Model.UserName%&GT;

变为

@ Model.UserName

&LT;%的foreach(在名称列表字符串名称){..}%GT;

变为

@foreach(在名称列表字符串名称){...}

有比这更给它一点,但不多。

There's a little more to it than that, but not much.

这篇关于ASP.NET MVC或剃刀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆