剃刀Comparions VS ASPX语法 [英] Comparions of Razor vs ASPX syntax

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

问题描述

最近我一直在进入MVC3和剃刀,阅读几篇文章有关这些主题,以更好地理解这个概念。

Recently I've been getting into MVC3 and Razor, and reading several articles about these topics to better understand the concept.

我一直在阅读斯科特Guthrie的博客文章,在他提供了以下2个例子。首先是ASPX语法,第二个是剃刀语法:

I've been reading Scott Guthrie's Blog Post, in which he provides the following 2 examples. The first being ASPX syntax, the second being Razor syntax:

这是伟大的,但作为ASPX和剃刀的一个公平的比较,我有点糊涂了。

This is great, but as a fair comparison of ASPX and Razor I'm a bit confused.

我从来没有见过这样的ASPX语法的任何工作示例。当然,开发人员使用转发控制等,因为ASP.NET被释放?我还没有看到类似语法,由于传统的ASP。

I've never seen any working example of ASPX syntax like that. Surely developers have used Repeater controls etc since ASP.NET was released? I haven't seen syntax like that since Classic ASP.

我一直以为这是不好的做法,把与标记文件编程code内联,而不是隐藏文件code。

I always thought it was bad practice to put programming code inline with the markup file, instead of the code behind file.

做任何ASP.NET开发人员ASPX code这样?

Do any ASP.NET ASPX developers code like this?

推荐答案

我想你肯定是越来越糊涂了。你的第一个例子是不是传统的asp.net。这是什么MVC渲染用于使用pre-剃刀引擎(MVC 1安培; MVC 2 - 我相信被称为WebForms的视图引擎)。

I think you are definitely getting confused. Your first example is not traditional asp.net. It is what the MVC render engine used to used pre-razor (MVC 1 & MVC 2 - which I believe is called the WebForms view engine).

<击>我很肯定你不能在传统的ASP.Net网页使用foreach。(帆的评论纠正我在这个)

I am very sure you cannot use a foreach in traditional ASP.Net pages. (Veli's comment corrected me on this)

使用MVC 3,你可以选择使用它,你可以看到的例子中的Razor视图引擎更具可读性。当然,随着MVC 3,你还可以选择做它的其他方式,这是创建初始的项目,当你选择一个选项。

With MVC 3 you can choose to use the Razor view engine which as you can see in the example is much more readable. Of course, with MVC 3 you can still choose to do it the other way, this is an option you select when creating the initial project.

您可以阅读更多关于这里的差异

这篇关于剃刀Comparions VS ASPX语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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