What is view engine? What does it actually do?

后端 未结 10 857
名媛妹妹
名媛妹妹 2020-12-13 08:24

I started learning ASP.NET MVC3.

So, while reading tutorials online and in books, I came across this term \"view engine\" quite frequently. I don\'t know

相关标签:
10条回答
  • 2020-12-13 09:13

    In ASP.Net MVC, View engine is the one that works between your view and browser to provide valid HTML output to your browser by considering output provided by your view.There are many types of view engines.

    1)ASPX

    2)Razor

    3)Spark

    4)NHaml

    5)NDJango

    6)Hasic

    7)Brail

    0 讨论(0)
  • 2020-12-13 09:14

    I read a descriptive post at http://questionbox.in/view-engine-asp-net-mvc-razor-view-engine-asp-net-mvc-web-form-aspx-view-engine-asp-net-mvc/

    View engine gives the ability to render the HTML from your view to the browser.

    There are many view engines supported by ASP.NET MVC but the most widely used view engines are

    • Web form / ASPX view engine.
    • Razor view engine.

    Web form view engine / ASPX view engine:

    • Web Form View Engine / ASPX View Engine is the default view engine for the Asp.net MVC project. It is available from MVC 1.0
    • The namespace for Web Form Engine is Web.Mvc.WebFormViewEngine
    • File Extension for this View Engine is similar to Web Form as:

    .aspx, for Views just like Web Form pages. .ascx, for Partial Views & Editor Template just like User Controls. .master, for Layout and Master Pages just like Master Pages in Web Forms.

    • No support for TDD (Test Driven Development).
    • Web Form Engine does not prevent XSS attacks means any script saved in the database will be fired while rendering the page
    • Syntax : <%: Html.ActionLink(“Home”, “Index”) %>

    Razor View Engine:

    • The Razor View Engine is an advanced view engine, available with MVC 3.0 and later versions
    • Namespace for ASPX view Engine is Web.Razor.
    • File Extension for this View Engine is .cshtml (Razor C#), for Views, Partial Views, Editor Template and Layout Pages. .vbhtml (Razor VB.NET), for Views, Partial Views, Editor Template and Layout Pages.
    • Supports TDD (Test Driven Development).
    • Razor Engine is little bit slow as compared to Web form Engine.
    • Razor Engine prevents XSS attacks(Cross-Site Scripting Attacks) means it encodes the script or html tags like <,> before rendering to view.
    • Razor syntax is easy to understand and much clean than Web Form syntax. Razor uses @ symbol to make the code like as:

      @Html.ActionLink(“Home”, “Index”)

    0 讨论(0)
  • 2020-12-13 09:18

    In MVC, View engine is the one that works between your View and browser to provide valid HTML output to your browser by compiling the code inside your View. There are many view engines available and some of them are following:

    1. ASPX

    2. Razor

    3. Spark

    4. NHaml

    5. NDJango

    6. Hasic

    7. Brail

    8. Bellevue

    9. Sharp Tiles

    10. String Template

    11. Wing Beats

    12. SharpDOM

    Currently most developers prefer to use Razor view engine as it provides very convenient way of programming. All of these view engines may not support ASP.NET MVC.

    For more details you can visit this article.

    0 讨论(0)
  • 2020-12-13 09:20

    View Engine renders the view into HTML form to the browser. If we talk about an MVC application in the .Net Framework, it supports the following 2 view engines:

    1. Razor View Engine 2. Web Form/ASPX View Engine

    Differences : 1. Razor View Engine uses Layouts but ASPX view engine uses Master pages.

    2. Razor View Engine uses partial page but ASPX view engine uses Web User Control.

    3. Razor view engine is not a language, It is Markup syntax.

    4. @’ symbol uses in Razor Engine to write the code. @Html.ActionLink("Login", "LoginView") ‘<%:’ delimiters use as starting point and ‘ %>’ use as ending point. You can write the code between them in ASPX Engine.

    5. Razor View Engine has .cshtml (with C#) and .vbhtml (with VB) extension for views, Layout and Partial views. ASPX View Engine has a similar extension as in a simple web application like .aspx for the views, .acsx for UserControls and .master for Master Pages.

    0 讨论(0)
提交回复
热议问题