Question 1 : What is Razor?
Answer: Razor is a markup syntax that lets you embed server-based code (Visual Basic and C#) into web pages.
Server-based code can create dynamic web content on the fly, while a web page is written to the browser. When a web page is called, the server executes the server-based code inside the page before it returns the page to the browser. By running on the server, the code can perform complex tasks, like accessing databases.
Razor is based on ASP.NET, and designed for creating web applications. It has the power of traditional ASP.NET markup, but it is easier to use, and easier to learn.
Question 2:What are Razor Programming Languages?
Answer :Razor supports both C# (C sharp) and VB (Visual Basic).
Question 3: What is Razor Helpers?
Answer :ASP.NET helpers are components that can be accessed by single lines of Razor code.
You can build your own helpers using Razor syntax, or use built-in ASP.NET helpers.
Below is a short description of some useful Razor helpers:
Web Grid
Web Graphics
Google Analytics
Facebook Integration
Twitter Integration
Sending Email
Validation
Question 4: Is, Razor is a case senstive language or Not?
Answer : Yes, Razor is case senstive language.
Question 5: What is Variables in Razor?
Answer :Variables are named entities used to store data.The name of a variable must begin with an alphabetic character and cannot contain whitespace or reserved characters.
Question 6: How can you use Razor to serve bundled CSS or JavaScript files?
Answer :In a nutshell? Very cleanly in an intuitive way. MVC 4 has a brand new syntax to serve bundled content as shown:
@Scripts.Render("~/Scripts/cart/js")
@Styles.Render("~/Content/cart/css", "~/Content/order/css")
Question 7:What are the Advantages of Razor View Engine ?
Answer :Compact, Expressive, and Fluid: Razor minimizes the number of characters and keystrokes required in a file, and enables a fast, fluid coding workflow. Unlike most template syntaxes, you do not need to interrupt your coding to explicitly denote server blocks within your HTML. The parser is smart enough to infer this from your code. This enables a really compact and expressive syntax which is clean, fast and fun to type.
Easy to Learn: Razor is easy to learn and enables you to quickly be productive with a minimum of concepts. You use all your existing language and HTML skills.
Is not a new language: We consciously chose not to create a new imperative language with Razor. Instead we wanted to enable developers to use their existing C#/VB (or other) language skills with Razor, and deliver a template markup syntax that enables an awesome HTML construction workflow with your language of choice.
Works with any Text Editor: Razor doesn’t require a specific tool and enables you to be productive in any plain old text editor (notepad works great).
Has great Intellisense: While Razor has been designed to not require a specific tool or code editor, it will have awesome statement completion support within Visual Studio. We’ll be updating Visual Studio 2010 and Visual Web Developer 2010 to have full editor intellisense for it.
Unit Testable: The new view engine implementation will support the ability to unit test views (without requiring a controller or web-server, and can be hosted in any unit test project – no special app-domain required).
Question 8:In which part of the Asp.net MVC Page life cycle,Razor engine will be used ?
Answer :Razor kicks in at Execute result in asp.net MVC Page life cycle.
Question 9: What is the file extension of Razor view engine ?
Answer :Web pages with Razor syntax have the special file extension cshtml (Razor with C#) or vbhtml (Razor with VB).
Question 10. What Template does Razor view engine uses ?
Answer :Instead of MasterPages for the template, Razor uses Layouts.
Question 11. How to add Namespaces in Razor view engine?
Answer : @using YourCustomNamespace
Eg : @using EmployeeNamespace
Question 12. How Variables are declared in Razor View Engine ?
Answer :Variables are declared with the var keywords.
Question 13. How inline expressions are declared in Razor View Engine?
Answer :All the inline expressions like variables and functions start with @.
Eg: <li @Html.Css("selected", Model.Mode == "map" )>STUFF</li>
Question 14. What are the Different View engines which can be used in asp.net MVC ?
Answer :Asp.net supports different view engines apart from Razor and Asp.net View Engine.
No comments:
Post a Comment