Asp.Net Web表单VS Asp.Net网站(剃刀)VS Asp.Net MVC

Asp.Net Web表单VS Asp.Net网站(剃刀)VS Asp.Net MVC

问题描述:

我认为微软必须对剃刀语法增强ASP.Net的原因。

I think Microsoft must have a reason for enhancing ASP.Net with RAZOR syntax.

创建新网站项目的Visual Studio中的对话框,没有用于创建ASP.Net(剃刀),另一种选择。我第一次在整个任期的剃须刀的是,当我读了一本书上Asp.Net MVC,我不知道它的存在为ASP.Net

On the Create New Website Project dialog of visual studio, there is another option for creating ASP.Net (Razor). The first time I came across the term Razor was when I read a book on Asp.Net MVC, I didn't know it exists for ASP.Net

我知道剃刀语法是什么,在MVC 3推出问这个问题之前,我决定创建ASP.Net(剃刀)一个测试项目,看看它是如何从正常的ASP.Net Web表单不同, ASP.Net MVC。我发现没有任何模型/视图/控制器的文件夹一样,我们在MVC。

I know what the Razor syntax is for, introduced in MVC 3. Before asking this question, I decided to create a test project for ASP.Net (Razor) and see how it is different from the normal ASP.Net webforms and ASP.Net MVC. I discovered no Model/View/Controllers folders like we have in MVC.

我发现母版页指定不同和法师页面干净,没有更多的< ASP:的ContentPlaceHolder />

I discovered that the Master page is specified differently and the Master page is cleaner, no more <asp:ContentPlaceHolder />

不过,我的问题是:


  • 我注意到它使用 .cshtml ,还有没有更多的codebehinds?

  • ASP.Net(剃刀)与ASP.Net MVC的
  • 异同

  • 是否可以延伸,就像ASP.Net MVC例如发挥作用加入控制器?查看/型号,自定义路由我猜?

  • 为什么这个存在的时候,我们有ASP.Net MVC?这是不是鼓励不情愿搬到ASP.Net MVC?

  • 为什么你会选择ASP.Net +剃刀在ASP.Net MVC?

  • I notice it uses .cshtml, are there no more codebehinds?
  • similarities and differences between ASP.Net (Razor) and ASP.Net MVC
  • Can it be extended to function like ASP.Net MVC e.g. adding Controller?View/Model, Custom Routing I guess?
  • Why does this exist when we have ASP.Net MVC? Wouldn't this encourage reluctance to move to ASP.Net MVC?
  • and why would you choose ASP.Net+Razor over ASP.Net MVC?

更新: ASP.NET尤其是网页设计来很容易让
  谁的人已经知道HTML服务器处理添加到自己的网页。
  这对学生,业余爱好者,一般人谁是一个不错的选择
  新的节目。它也可以是为开发一个好的选择谁
  有non-ASP.NET网络技术经验

UPDATE: ASP.NET Web Pages in particular was designed to make it easy for people who already know HTML to add server processing to their pages. It's a good choice for students, hobbyists, people in general who are new to programming. It can also be a good choice for developers who have experience with non-ASP.NET web technologies

更新 ASP.NET网页 ASP.NET网页针对谁想要一个简单的Web开发故事开发,PHP沿线的线路。在网页的模式,你
  创建HTML页面,然后添加基于服务器的code页面,以便
  动态地控制标记的呈现方式。网页是
  专门设计为一个轻便的框架,并且它的
  最简单的切入点ASP.NET的,谁知道HTML,但可能人
  没有广泛的编程经验 - 例如,学生或
  业余爱好者。这也是对于Web开发人员的好办法,谁知道PHP或
  类似的框架开始使用ASP.NET。

Update ASP.NET Web Pages ASP.NET Web Pages targets developers who want a simple web development story, along the lines of PHP. In the Web Pages model, you create HTML pages and then add server-based code to the page in order to dynamically control how that markup is rendered. Web Pages is specifically designed to be a lightweight framework, and it's the easiest entry point into ASP.NET for people who know HTML but might not have broad programming experience — for example, students or hobbyists. It's also a good way for web developers who know PHP or similar frameworks to start using ASP.NET.

Asp.Net网页

请,我需要你的技术意见。
谢谢你。

Please, I need your technical opinion. Thanks.

这是一个很大的问题。首先,让我们刻画剃刀。

This is a great question. First, lets characterize Razor.

剃刀是解析服务器端code。将发出的Html,就像ASP.NET Web窗体只是用不同的,可以说是更加精简和简洁的语法发动机。

Razor is an engine that parses server-side code an emits Html, just like ASP.NET Web Forms only with different and arguably more streamlined and terse syntax.

剃刀v Web窗体边栏:在ASP.NET Web窗体,你必须确定,当你想开始写服务器code。与'&LT;%',然后当你写完服务器code你需要确定与%>。我爱ASP.NET Web窗体,但这是笨重。剃刀你确定何时要开始写服务器code。与'@',然后在下次开始编写服务器标记时间(以'&LT;')为计算出你与服务器完成code。这是写一些服务器code混合HTML更简洁的方式。

Razor v. Web Forms Sidebar: In ASP.NET Web Forms you have to identify when you wanted to start writing server code with '<%' and then when you were done writing server code you needed to identify that with '%>'. I love ASP.NET Web Forms, but that's clunky. With Razor you identify when you want to start writing server code with '@' and then the next time you start writing a server tag (starting with '<') it "figures out" that you're done with server code. It's a more concise way to write html intermingled with some server code.

ASP.NET网页是用于创建简单的Web应用程序的框架。 ASP.NET MVC是与任何Web窗体或使用模型 - 视图 - 控制器(MVC)模式剃刀引擎创建Web应用程序的框架。 ASP.NET Web窗体是创建使用Web窗体渲染引擎的Web应用程序的框架。

ASP.NET Web Pages is a framework for creating simple Web Applications. ASP.NET MVC is a framework for creating web applications with either the Web Forms or Razor engine using the Model-View-Controller (MVC) pattern. ASP.NET Web Forms is a framework for creating web applications using the Web Forms render engine.

最终的目标是基于正在构建的应用程序的复杂性,以提供选择。了解每个帮助您做出正确的选择,为您的应用。

Ultimately the goal is to provide choice based on the sophistication of the application that is being built. Understanding each with assist you in making the correct choice for your application.

其他链接:

  • ScottGu's Blog - Introducing Razor
  • ScottGu's Blog - Introducing WebMatrix
  • ASP.NET Web Page with Razor Syntax (MSDN)