ASPX and Razor View Engine introduced in MVC3

Razor is an alternative view engine for MVC apps, and is implemented by entirely different code than .aspx

The Razor Syntax, Server Code, and ASP.NET

Razor syntax is a simple programming syntax for embedding server-based code in a web page. In a web page that uses the Razor syntax, there are two kinds of content: client content and server code. Client content is the stuff you’re used to in web pages: HTML markup (elements), style information such as CSS, client script such as JavaScript, and plain text.
Razor syntax lets you add server code to this client content. If there’s servercode in the page, the server runs that code first, before it sends the page to the browser. By running on the server, the code can perform tasks that can be a lot more complex to do using client content alone, like accessing server-based databases. Most importantly, server code can dynamically create client content — it can generate HTML markup or other content on the fly and then send it to the browser along with any static HTML that the page might contain. From the browser’s perspective, client content that’s generated by your server code is no different than any other client content. As you’ve already seen, the server code that’s required is quite simple.
ASP.NET web pages that include the Razor syntax have a special file extension (.cshtml or .vbhtml). The server recognizes these extensions, runsthe code that’s marked with Razor syntax, and then sends the page to the browser.

Source : –

No Comments Yet.

Leave a comment