Razor和ASP.Net Engine有什么区别 [英] what is the difference between Razor and ASP.Net Engine

查看:152
本文介绍了Razor和ASP.Net Engine有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i不知道Razor视图引擎和Asp.Net引擎有什么区别和

有什么缺点Asp.net。

为什么Viewstate是ASp.Net的劣势请给我全部。

坦克你。

Hi,

i have no idea what is the difference between Razor view Engine and Asp.Net Engine and
what are the disadvantages of Asp.net.
why Viewstate is disadvantage of ASp.Net please give me full on it.
Tanking you.

推荐答案

Razor View引擎

1. Razor Engine是一款先进的视图引擎与MVC3。这不是一种新语言,但它是一种新的标记语法。



2. Razor Engine使用的文件扩展名与Web Form Engine不同。它有.cshtml(Razor with C#)或.vbhtml(Razor with VB)扩展,用于视图,部分视图,编辑器模板和布局页面。



3. Razor具有新颖且先进的语法,紧凑,富有表现力并减少打字。



4. Razor语法比Web Form语法易学易懂。 Razor使用@符号来制作如下代码:



@ Html.ActionLink(SignUp,SignUp)



5. Razor Engine支持TDD(测试驱动开发),因为它不依赖于System.Web.UI.Page类。



Web窗体视图引擎



1. Web窗体引擎是默认的视图引擎从一开始就包含在Asp.net MVC中的Asp.net MVC。



2.与Web Form Engine一起使用的文件扩展名也像Asp.net Web形式。它的视图扩展名为.aspx,部分视图的扩展名为.ascx&布局/母版页的编辑器模板和.master扩展名。



3. Web窗体引擎具有与Asp.net Web窗格用于.aspx页面相同的语法。



4.
Razor View Engine
1. Razor Engine is an advanced view engine that was introduced with MVC3. This is not a new language but it is a new markup syntax.

2. The file extensions used with Razor Engine are different from Web Form Engine. It has .cshtml (Razor with C#) or .vbhtml (Razor with VB) extension for views, partial views, editor templates and for layout pages.

3. Razor has new and advance syntax that are compact, expressive and reduces typing.

4. Razor syntax are easy to learn and much clean than Web Form syntax. Razor uses @ symbol to make the code like as:

@Html.ActionLink("SignUp", "SignUp")

5. Razor Engine support TDD (Test Driven Development) since it is not depend on System.Web.UI.Page class.

Web Form View Engine

1. Web Form Engine is the default view engine for the Asp.net MVC that is included with Asp.net MVC from the beginning.

2. The file extensions used with Web Form Engine are also like Asp.net Web Forms. It has .aspx extension for views, .ascx extension for partial views & editor templates and .master extension for layout/master pages.

3. Web Form Engine has the same syntax like Asp.net Web Forms uses for .aspx pages.

4.
Web Form syntax are borrowed from Asp.net Web Forms syntax that are mixed with html and sometimes make a view messy. Webform uses <% and %> delimiters to make the code like as:

 <%: Html.ActionLink("SignUp", "SignUp") %>





5. Web表单引擎不支持TDD(测试驱动开发),因为它依赖于System。 Web.UI.Page类使测试变得复杂。



5. Web Form Engine doesn't support TDD (Test Driven Development) since it depend on System.Web.UI.Page class which makes the testing complex.


阅读更多这里 [ ^ ]和这里 [ ^ ]。



[ ^ ]可能会给一些额外的信息好吧。
Read more here[^] and here[^].

This[^] might give some additional information as well.


主要区别在于您在asp.net引擎中使用的脚本< %%>和Razor查看@



使用Razor视图编写代码更容易,因为程序员不需要结束标记



程序员可以轻松添加带HTML代码的脚本代码



因为MVC是开源的其他视图引擎也可以像:Spark



主要的区别只不过是所有这些都是为了让程序员的生活更轻松而开发



你可以参考: HTTP:/ /ironshay.com/post/The-Big-View-Engine-Comparison-e28093-Razor-vs-Spark-vs-NHaml-vs-Web-Forms-View-Engine.aspx [ ]



我们知道HTTP状态较少,一旦表单发布到,就无法存储任何信息SER虽然asp.net甚至我们回发表单切断它保留每个服务器端控件的状态



asp.net使用viewstate来保存asp。 net control在post back上的状态。

asp.net为你使用的每个服务器端控件添加了viewstate额外代码

它将增加HTML代码(发送给客户端的响应)并且达到应用程序的性能

因此建议不要使用viewstate来控制哪个值不需要保留在服务器回发上
The main differences is the script you are using in asp.net engine "<%%>" and Razor view "@"

It is more easy to write code with Razor view as programmer not need to end the tag

programmer can easily add the scripting code with HTML code

as MVC is open source other view engines are also available like :Spark

The major differences are nothing but all those are develop to make programmer life easy

you can refer:http://ironshay.com/post/The-Big-View-Engine-Comparison-e28093-Razor-vs-Spark-vs-NHaml-vs-Web-Forms-View-Engine.aspx[]

We know that HTTP is state less, It is not able to store the any information once the form is posted to server although asp.net even we are postback the form to sever It preserve the status of each sever side control

The asp.net is using viewstate to preserve the asp.net control's status on post back.
asp.net added viewstate extra code for each server side control you used
It will increases the HTML code (response that send to client)and hit the performance of application
so it advisable to not to use the viewstate for the control which value not require to preserve on server postback


这篇关于Razor和ASP.Net Engine有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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