Articles → ASP .NET MVC → View Engines In Asp.Net MVC
View Engines In Asp.Net MVC
- ASPX view engine
- Razor view engine.
ASPX View Engine
- Extension of all your files in view folder is .aspx
Click to Enlarge
- < % % > is used for accessing server-side code
<p><%
if (DateTime.Now.Day == 19)
{%>
Execute code block 1
<%}else {%>
Execute code block 2
<%} %>
</p>
Razor View Engine
- Extension of all your files in view folder is .cshtml for C# and .vbhtml for vb.net.
Click to Enlarge
- @ is used for accessing server-side code.
<p>
Use this area to provide additional information.
@if (DateTime.Now.Day == 19)
{
<text> Execute Code block 1</text>
}
else
{
<text>Execute Code block 2</text>
}
</p>
What is the difference between razor and webform view engine?
Razor view engine | Webform view engine |
---|
Razor view engine uses System.Web.Razor namespace | Webform view engine uses System.Web.Mvc. WebformViewEngine namespace |
Razor view engine uses @ syntax | Webform view engine uses < % %> |
Razor view engine prevents XSS attack | Webform view engine does not prevents XSS attack |
Razor view engine is slow as compared to webform view engine. | Webform view engine is quicker in performance as compared to razor view engine. |
Razor view engine supports test driven approach | Webform view engine does not support test driven approach |