In this blog, I want to share some important notes on RazorEngine in ASP.NET MVC5


  1. MVC5 uses view engine to allow using Razor inside MVC Web Application to build HTML output.
  2. Razor coding is a combination of C#.NET or VB.NET and HTML design
  3. We use languages to get the data and generate the output.
  4. Easy to use, to learn, and to work with in real time environment scenarios.
  5. Razor Expressions 

    1. Single line C# Statement

       Syntax
      1. <p>@ViewBag.Name </p>  
  6. Razor blocks

    1. Multiline line statements

      Syntax
      1. @{  
      2. //statement(s)  
      3. .....  
      4. }  
      Razor block code can have both combinations of C# and HTML language codes.
      for example.



      Output



      @ Symbol uses in razor engine to write the code, as shown below.
      @Html.ActionLink (“SignIn’,”Account”);

The main advantage of RazorEngine prevents cross-site scripting attacks like <> before rendering to view.

Thanks for reading my blog.