Part 2 - View engines in asp.net mvc
2016-10-14 15:36
405 查看
Out of the box asp.net offers the following 2 view engines.
1. ASPX
2. Razor
There are 3 possible interview questions here, to test your understanding of view engines.
1. What is the difference between RAZOR and ASPX view engines?
It mostly, boils down to the syntax. Otherwise there are no major differences between the two. In ASPX view engine, the server side script is wrapped between <% %>,
where as in RAZOR we use @. Personally, I prefer using RAZOR views, as it is very easy to switch between HTML and Code.
Depending on the programming language you have chosen, RAZOR views have the extension of .CSHTML or .VBHTML, where as ASPX views has the extension of .ASPX
2. Is it possible, to have both RAZOR and ASPX views in one application?
Yes, when you right click on any controller action method, and select "Add View" from the context menu, you will have the option to choose the view engine of your choice from the "Add View"
dialog box.
3. Is it possible, to use a third party view engine with asp.net mvc?
ASP.NET MVC is designed with extensibility in mind. So, it's very easy to include third party view engine as well. We will discuss this in detail in our next video.
1. ASPX
2. Razor
There are 3 possible interview questions here, to test your understanding of view engines.
1. What is the difference between RAZOR and ASPX view engines?
It mostly, boils down to the syntax. Otherwise there are no major differences between the two. In ASPX view engine, the server side script is wrapped between <% %>,
where as in RAZOR we use @. Personally, I prefer using RAZOR views, as it is very easy to switch between HTML and Code.
Depending on the programming language you have chosen, RAZOR views have the extension of .CSHTML or .VBHTML, where as ASPX views has the extension of .ASPX
2. Is it possible, to have both RAZOR and ASPX views in one application?
Yes, when you right click on any controller action method, and select "Add View" from the context menu, you will have the option to choose the view engine of your choice from the "Add View"
dialog box.
3. Is it possible, to use a third party view engine with asp.net mvc?
ASP.NET MVC is designed with extensibility in mind. So, it's very easy to include third party view engine as well. We will discuss this in detail in our next video.
相关文章推荐
- Part 3 - Using custom view engines with asp.net mvc
- 【转】ASP.NET MVC 3 Service Location, Part 3: View Engines/View Pages
- Part 60 - ViewStart in asp.net mvc
- How to use jquery or ajax to update razor partial view in c#/asp.net for a MVC project
- ASP.NET MVC 2.0 in Vs2010 :使用C# 4.0中使用动态类型来传递ViewData
- Part 83 - RegularExpression attribute in asp.net mvc
- ASP.NET MVC- VIEW Creating Page Layouts with View Master Pages Part 4
- 【转】ASP.NET MVC 3 Service Location, Part 11: View Page Activator
- Part 81 - Range attribute in asp.net mvc
- Part 88 - Unobtrusive validation in asp.net mvc
- Part 54 - T4 templates in asp.net mvc
- ASP.NET MVC - View Engines
- Part 86 - ValidationSummary in asp.net mvc
- ASP.NET MVC- VIEW Creating Custom HTML Helpers Part 2
- Display a view from another controller in ASP.NET MVC
- View components and Inject in ASP.NET MVC 6
- ASP.NET MVC- VIEW Using the TagBuilder Class to Build HTML Helpers Part 3
- ASP.NET MVC 2.0 in Vs2010 :使用C# 4.0中使用动态类型来传递ViewData
- Part 85 - Enable client side validation in asp.net mvc
- Part 89 - Remote validation in asp.net mvc