• home
  • Email: trainings@synapseindia.careers

Blogs

back

Creating a Web Site using Razor Syntax in Visual Studio

Jun 30, 2015

ASP.NET Web Pages with Razor syntax provides a simple programming syntax for writing code in Web pages where the server-based code is embedded into the Web page HTML markup. The Razor code runs on the server before the page is sent to the browser. This server code can dynamically create client content—that is, 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 contains.

Web Pages with Razor syntax provide an alternative to ASP.NET Web Forms. Web Forms pages center around Web server controls that generate HTML automatically and that emulate the event-based programming model used for client applications. In contrast, Razor pages work more directly like standard HTML pages, where you create virtually all of the HTML markup yourself and where you then add functionality around that markup using server code. In general, Razor pages are more lightweight than Web Forms pages. Because of that and because the syntax is simple, Razor can be easier for programmers to learn and can be faster for developing dynamic Web pages.

Web pages that contain Razor content have a special file extension (.cshtml or .vbhtml). The server recognizes these extensions, runs the code that's marked with Razor syntax, and then sends the resulting page to the browser.

 SynapseIndia (CEO: Shamit Khemka)