SlideShare a Scribd company logo
1 of 15
Introducing Razor A new view engine for ASP.NET Shiju Varghese Blog : http://weblogs.asp.net/shijuvarghese Twitter : http://twitter.com/shijucv Email : shiju.varghese@gmail.com
Who Am I? Microsoft MVP on ASP.NET Solution Architect Focus on Microsoft Web Platform stack Agile Enthusiast Technology Consultant – Web Apps/ASP.NET MVC/EF Blog: http://weblogs.asp.net/shijuvarghese Twitter: @shijucv
Session Objectives Introduction to Razor Introduction to Razor Syntax Demonstrate Razor syntax in ASP.NET MVC 3 Views
New tools from Microsoft Web Platform Web Matrix IIS Express ASP.NET Web Pages SQL Server Compact  Razor  NuGet
Introduction to Razor A new view-engine option for ASP.NET A simplified syntax Its not a new language  A code focused templating syntax optimized around HTML generation Shared by ASP.Netweb pages and ASP.Net MVC Works with any Text Editor IntelliSense with Visual Studio 2010/ VWD 2010 CSHTML (C#) and VBHTML (VB.NET) Unit Testable
ASP.NET Razor Support ASP.NET Web Pages Using for inline programming ASP.NET MVC 3 Using for ASP.NET MVC Views Tools Web Matrix Visual Studio 2010 Visual Web Developer 2010 Languages C# VB.Net
@ character @ character is using for insert server side code Single statement blocks @{ varmyMessage = "Hello World"; } Starts inline expressions <p>The value of myMessage is: @myMessage</p> Multi-statement blocks @{ var greeting = "Welcome to our Razor!"; varweekDay = DateTime.Now.DayOfWeek; vargreetingMessage = greeting + " Today is: " + weekDay; }
Razor Syntax Web Forms syntax 	<% for (int i = 0; i < 10; i++) { %> 	     <li><% =i %></li> 	<% } %> Razor syntax 	@for (int i = 0; i < 10; i++) { 		<li>@i</li> 	}
Razor Syntax @{ var name = “Shiju”; var title=“Architect”; 	<div> Name: @name 	Title: @title  	</div> }
Layout page Share common html across many pages Layout page: _LayoutPage.cshtml <html> <title>@Page.Title</title> <body> <div> @Html.Partial("_Header")  </div> @RenderBody() <div> @Html.Partial("_Footer")</div> </body>
Using Layout page @{ Page.Title = “Your Page Title”; 	Layout = "_Layout.cshtml"; }
_PageStart.cshtml Run code for each page Setup layout page for an entire folder
Using Helper App_Code/RazorHelper.cshtml @helper ShowCopyright() { <div> Copyright Shiju Varghese @DateTime.Now.Year </div> Using a Helper @RazorHelper.ShowCopyright()
Demo
Thanks

More Related Content

What's hot

MVC4 framework
MVC4 frameworkMVC4 framework
MVC4 frameworkimarkovic
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCSirwan Afifi
 
Future ASP.NET features for UID / HTML developers
Future ASP.NET features for UID / HTML developersFuture ASP.NET features for UID / HTML developers
Future ASP.NET features for UID / HTML developersMark Everard
 
Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs Nir Kaufman
 
TRAX technical highlights
TRAX technical highlightsTRAX technical highlights
TRAX technical highlightsESUG
 
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...ESUG
 
Head first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rttHead first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rttLanvige Jiang
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009ken.egozi
 
Advanced MVC3
Advanced MVC3Advanced MVC3
Advanced MVC3shobokshi
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScriptAhmed El-Kady
 
Magento 2 Community Project - Moving from LESS to SASS
Magento 2 Community Project - Moving from LESS to SASSMagento 2 Community Project - Moving from LESS to SASS
Magento 2 Community Project - Moving from LESS to SASSBartek Igielski
 
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...Refresh Events
 

What's hot (20)

MVC4 framework
MVC4 frameworkMVC4 framework
MVC4 framework
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Future ASP.NET features for UID / HTML developers
Future ASP.NET features for UID / HTML developersFuture ASP.NET features for UID / HTML developers
Future ASP.NET features for UID / HTML developers
 
ASP.NET - Ivan Marković
ASP.NET - Ivan MarkovićASP.NET - Ivan Marković
ASP.NET - Ivan Marković
 
Controls
ControlsControls
Controls
 
Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs
 
TRAX technical highlights
TRAX technical highlightsTRAX technical highlights
TRAX technical highlights
 
AngularU Recap
AngularU RecapAngularU Recap
AngularU Recap
 
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
 
Ng talk
Ng talkNg talk
Ng talk
 
Head first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rttHead first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rtt
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
 
Advanced MVC3
Advanced MVC3Advanced MVC3
Advanced MVC3
 
Ajax
AjaxAjax
Ajax
 
Monorail Introduction
Monorail IntroductionMonorail Introduction
Monorail Introduction
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
 
Magento 2 Community Project - Moving from LESS to SASS
Magento 2 Community Project - Moving from LESS to SASSMagento 2 Community Project - Moving from LESS to SASS
Magento 2 Community Project - Moving from LESS to SASS
 
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
ASP .Net MVC 5
ASP .Net MVC 5ASP .Net MVC 5
ASP .Net MVC 5
 

Viewers also liked

The Promised Land (in Angular)
The Promised Land (in Angular)The Promised Land (in Angular)
The Promised Land (in Angular)Domenic Denicola
 
Boom! Promises/A+ Was Born
Boom! Promises/A+ Was BornBoom! Promises/A+ Was Born
Boom! Promises/A+ Was BornDomenic Denicola
 
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And NavigationEyal Vardi
 
Angular 2 NgModule
Angular 2 NgModuleAngular 2 NgModule
Angular 2 NgModuleEyal Vardi
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0Eyal Vardi
 
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xUpgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xEyal Vardi
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Eyal Vardi
 
Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injectionEyal Vardi
 
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time CompilationAngular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time CompilationEyal Vardi
 
Performance Optimization In Angular 2
Performance Optimization In Angular 2Performance Optimization In Angular 2
Performance Optimization In Angular 2Eyal Vardi
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xEyal Vardi
 
Creating Custom HTML Helpers in ASP.NET MVC
Creating Custom HTML Helpers in ASP.NET MVCCreating Custom HTML Helpers in ASP.NET MVC
Creating Custom HTML Helpers in ASP.NET MVCLohith Goudagere Nagaraj
 
Rachel's grandmother's recipes
Rachel's grandmother's recipesRachel's grandmother's recipes
Rachel's grandmother's recipesEyal Vardi
 
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraAllen Wirfs-Brock
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Eyal Vardi
 

Viewers also liked (20)

Views
ViewsViews
Views
 
The Promised Land (in Angular)
The Promised Land (in Angular)The Promised Land (in Angular)
The Promised Land (in Angular)
 
Async Frontiers
Async FrontiersAsync Frontiers
Async Frontiers
 
Boom! Promises/A+ Was Born
Boom! Promises/A+ Was BornBoom! Promises/A+ Was Born
Boom! Promises/A+ Was Born
 
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And Navigation
 
Angular 2 NgModule
Angular 2 NgModuleAngular 2 NgModule
Angular 2 NgModule
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
 
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.xUpgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
 
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
 
Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injection
 
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time CompilationAngular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time Compilation
 
Performance Optimization In Angular 2
Performance Optimization In Angular 2Performance Optimization In Angular 2
Performance Optimization In Angular 2
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
 
Creating Custom HTML Helpers in ASP.NET MVC
Creating Custom HTML Helpers in ASP.NET MVCCreating Custom HTML Helpers in ASP.NET MVC
Creating Custom HTML Helpers in ASP.NET MVC
 
Rachel's grandmother's recipes
Rachel's grandmother's recipesRachel's grandmother's recipes
Rachel's grandmother's recipes
 
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
 
Scaffolding in One Asp.Net
Scaffolding in One Asp.NetScaffolding in One Asp.Net
Scaffolding in One Asp.Net
 
Streams for the Web
Streams for the WebStreams for the Web
Streams for the Web
 
ES6 in Real Life
ES6 in Real LifeES6 in Real Life
ES6 in Real Life
 

Similar to Introducing Razor - A new view engine for ASP.NET

Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4Umar Ali
 
Software components design for poc and mvp, keep it simple but be ready to sc...
Software components design for poc and mvp, keep it simple but be ready to sc...Software components design for poc and mvp, keep it simple but be ready to sc...
Software components design for poc and mvp, keep it simple but be ready to sc...Roman Taluyev
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET PresentationRasel Khan
 
What are razor pages?
What are razor pages?What are razor pages?
What are razor pages?Mindfire LLC
 
Top 10 - ASP.NET Interview Questions And Answers 2023.pdf
Top 10 -  ASP.NET Interview Questions And Answers 2023.pdfTop 10 -  ASP.NET Interview Questions And Answers 2023.pdf
Top 10 - ASP.NET Interview Questions And Answers 2023.pdfRuddarpratap
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesAaron Jacobson
 
Murach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMurach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMahmoudOHassouna
 
TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0Shiju Varghese
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET CoreMiroslav Popovic
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentationteach4uin
 
Benefits of Using ASP.NET For Web Development for Businesses In 2023
Benefits of Using ASP.NET For Web Development for Businesses In 2023Benefits of Using ASP.NET For Web Development for Businesses In 2023
Benefits of Using ASP.NET For Web Development for Businesses In 2023CMARIX TechnoLabs
 

Similar to Introducing Razor - A new view engine for ASP.NET (20)

Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4
 
Software components design for poc and mvp, keep it simple but be ready to sc...
Software components design for poc and mvp, keep it simple but be ready to sc...Software components design for poc and mvp, keep it simple but be ready to sc...
Software components design for poc and mvp, keep it simple but be ready to sc...
 
Walther Aspnet4
Walther Aspnet4Walther Aspnet4
Walther Aspnet4
 
ASP.NET vNext Beta 3
ASP.NET vNext Beta 3ASP.NET vNext Beta 3
ASP.NET vNext Beta 3
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
What are razor pages?
What are razor pages?What are razor pages?
What are razor pages?
 
Top 10 - ASP.NET Interview Questions And Answers 2023.pdf
Top 10 -  ASP.NET Interview Questions And Answers 2023.pdfTop 10 -  ASP.NET Interview Questions And Answers 2023.pdf
Top 10 - ASP.NET Interview Questions And Answers 2023.pdf
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
 
Murach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMurach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVC
 
TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0
 
Asp.net Overview
Asp.net OverviewAsp.net Overview
Asp.net Overview
 
One ASP.NET
One ASP.NETOne ASP.NET
One ASP.NET
 
Asp.netrole
Asp.netroleAsp.netrole
Asp.netrole
 
Asp-net
 Asp-net Asp-net
Asp-net
 
Rutgers - Active Server Pages
Rutgers - Active Server PagesRutgers - Active Server Pages
Rutgers - Active Server Pages
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentation
 
Benefits of Using ASP.NET For Web Development for Businesses In 2023
Benefits of Using ASP.NET For Web Development for Businesses In 2023Benefits of Using ASP.NET For Web Development for Businesses In 2023
Benefits of Using ASP.NET For Web Development for Businesses In 2023
 
ASP.NET 4.0 Roadmap
ASP.NET 4.0 RoadmapASP.NET 4.0 Roadmap
ASP.NET 4.0 Roadmap
 

More from Shiju Varghese

Building Modern Distributed Applications in Go with Service Weaver
Building Modern Distributed Applications in Go with Service WeaverBuilding Modern Distributed Applications in Go with Service Weaver
Building Modern Distributed Applications in Go with Service WeaverShiju Varghese
 
Microservices in Go with Go kit
Microservices in Go with Go kitMicroservices in Go with Go kit
Microservices in Go with Go kitShiju Varghese
 
NATS: A Cloud Native Messaging System
NATS: A Cloud Native Messaging SystemNATS: A Cloud Native Messaging System
NATS: A Cloud Native Messaging SystemShiju Varghese
 
Event-Driven Microservices With NATS Streaming
Event-Driven Microservices With NATS StreamingEvent-Driven Microservices With NATS Streaming
Event-Driven Microservices With NATS StreamingShiju Varghese
 
Inter-Process Communication in Microservices using gRPC
Inter-Process Communication in Microservices using gRPCInter-Process Communication in Microservices using gRPC
Inter-Process Communication in Microservices using gRPCShiju Varghese
 
Building Microservices with gRPC and NATS
Building Microservices with gRPC and NATSBuilding Microservices with gRPC and NATS
Building Microservices with gRPC and NATSShiju Varghese
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersShiju Varghese
 
Building Scalable Backends with Go
Building Scalable Backends with GoBuilding Scalable Backends with Go
Building Scalable Backends with GoShiju Varghese
 
A Primer to Containerization & Microservices
A Primer to Containerization & MicroservicesA Primer to Containerization & Microservices
A Primer to Containerization & MicroservicesShiju Varghese
 
Writing HTTP Middleware In Go
Writing HTTP Middleware In GoWriting HTTP Middleware In Go
Writing HTTP Middleware In GoShiju Varghese
 
Building RESTful Services With Go and MongoDB
Building RESTful Services With Go and MongoDBBuilding RESTful Services With Go and MongoDB
Building RESTful Services With Go and MongoDBShiju Varghese
 
Practicing Mindfulness
Practicing MindfulnessPracticing Mindfulness
Practicing MindfulnessShiju Varghese
 
Azure Mobile Services .NET Backend
Azure Mobile Services .NET BackendAzure Mobile Services .NET Backend
Azure Mobile Services .NET BackendShiju Varghese
 
Windows Azure Mobile Services
Windows Azure Mobile ServicesWindows Azure Mobile Services
Windows Azure Mobile ServicesShiju Varghese
 
JavaScript, Meet Cloud : Node.js on Windows Azure
JavaScript, Meet Cloud : Node.js on Windows AzureJavaScript, Meet Cloud : Node.js on Windows Azure
JavaScript, Meet Cloud : Node.js on Windows AzureShiju Varghese
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node jsShiju Varghese
 
Windows Azure Cloud Services
Windows Azure Cloud Services Windows Azure Cloud Services
Windows Azure Cloud Services Shiju Varghese
 
Windows Azure Webs Sites
Windows Azure Webs SitesWindows Azure Webs Sites
Windows Azure Webs SitesShiju Varghese
 

More from Shiju Varghese (20)

Building Modern Distributed Applications in Go with Service Weaver
Building Modern Distributed Applications in Go with Service WeaverBuilding Modern Distributed Applications in Go with Service Weaver
Building Modern Distributed Applications in Go with Service Weaver
 
Microservices in Go with Go kit
Microservices in Go with Go kitMicroservices in Go with Go kit
Microservices in Go with Go kit
 
NATS: A Cloud Native Messaging System
NATS: A Cloud Native Messaging SystemNATS: A Cloud Native Messaging System
NATS: A Cloud Native Messaging System
 
Event-Driven Microservices With NATS Streaming
Event-Driven Microservices With NATS StreamingEvent-Driven Microservices With NATS Streaming
Event-Driven Microservices With NATS Streaming
 
Inter-Process Communication in Microservices using gRPC
Inter-Process Communication in Microservices using gRPCInter-Process Communication in Microservices using gRPC
Inter-Process Communication in Microservices using gRPC
 
Building Microservices with gRPC and NATS
Building Microservices with gRPC and NATSBuilding Microservices with gRPC and NATS
Building Microservices with gRPC and NATS
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol Buffers
 
Building Scalable Backends with Go
Building Scalable Backends with GoBuilding Scalable Backends with Go
Building Scalable Backends with Go
 
A Primer to Containerization & Microservices
A Primer to Containerization & MicroservicesA Primer to Containerization & Microservices
A Primer to Containerization & Microservices
 
Writing HTTP Middleware In Go
Writing HTTP Middleware In GoWriting HTTP Middleware In Go
Writing HTTP Middleware In Go
 
Building RESTful Services With Go and MongoDB
Building RESTful Services With Go and MongoDBBuilding RESTful Services With Go and MongoDB
Building RESTful Services With Go and MongoDB
 
Docker and Kubernetes
Docker and KubernetesDocker and Kubernetes
Docker and Kubernetes
 
Practicing Mindfulness
Practicing MindfulnessPracticing Mindfulness
Practicing Mindfulness
 
Azure DocumentDB
Azure DocumentDBAzure DocumentDB
Azure DocumentDB
 
Azure Mobile Services .NET Backend
Azure Mobile Services .NET BackendAzure Mobile Services .NET Backend
Azure Mobile Services .NET Backend
 
Windows Azure Mobile Services
Windows Azure Mobile ServicesWindows Azure Mobile Services
Windows Azure Mobile Services
 
JavaScript, Meet Cloud : Node.js on Windows Azure
JavaScript, Meet Cloud : Node.js on Windows AzureJavaScript, Meet Cloud : Node.js on Windows Azure
JavaScript, Meet Cloud : Node.js on Windows Azure
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Windows Azure Cloud Services
Windows Azure Cloud Services Windows Azure Cloud Services
Windows Azure Cloud Services
 
Windows Azure Webs Sites
Windows Azure Webs SitesWindows Azure Webs Sites
Windows Azure Webs Sites
 

Introducing Razor - A new view engine for ASP.NET

  • 1. Introducing Razor A new view engine for ASP.NET Shiju Varghese Blog : http://weblogs.asp.net/shijuvarghese Twitter : http://twitter.com/shijucv Email : shiju.varghese@gmail.com
  • 2. Who Am I? Microsoft MVP on ASP.NET Solution Architect Focus on Microsoft Web Platform stack Agile Enthusiast Technology Consultant – Web Apps/ASP.NET MVC/EF Blog: http://weblogs.asp.net/shijuvarghese Twitter: @shijucv
  • 3. Session Objectives Introduction to Razor Introduction to Razor Syntax Demonstrate Razor syntax in ASP.NET MVC 3 Views
  • 4. New tools from Microsoft Web Platform Web Matrix IIS Express ASP.NET Web Pages SQL Server Compact Razor NuGet
  • 5. Introduction to Razor A new view-engine option for ASP.NET A simplified syntax Its not a new language A code focused templating syntax optimized around HTML generation Shared by ASP.Netweb pages and ASP.Net MVC Works with any Text Editor IntelliSense with Visual Studio 2010/ VWD 2010 CSHTML (C#) and VBHTML (VB.NET) Unit Testable
  • 6. ASP.NET Razor Support ASP.NET Web Pages Using for inline programming ASP.NET MVC 3 Using for ASP.NET MVC Views Tools Web Matrix Visual Studio 2010 Visual Web Developer 2010 Languages C# VB.Net
  • 7. @ character @ character is using for insert server side code Single statement blocks @{ varmyMessage = "Hello World"; } Starts inline expressions <p>The value of myMessage is: @myMessage</p> Multi-statement blocks @{ var greeting = "Welcome to our Razor!"; varweekDay = DateTime.Now.DayOfWeek; vargreetingMessage = greeting + " Today is: " + weekDay; }
  • 8. Razor Syntax Web Forms syntax <% for (int i = 0; i < 10; i++) { %> <li><% =i %></li> <% } %> Razor syntax @for (int i = 0; i < 10; i++) { <li>@i</li> }
  • 9. Razor Syntax @{ var name = “Shiju”; var title=“Architect”; <div> Name: @name Title: @title </div> }
  • 10. Layout page Share common html across many pages Layout page: _LayoutPage.cshtml <html> <title>@Page.Title</title> <body> <div> @Html.Partial("_Header") </div> @RenderBody() <div> @Html.Partial("_Footer")</div> </body>
  • 11. Using Layout page @{ Page.Title = “Your Page Title”; Layout = "_Layout.cshtml"; }
  • 12. _PageStart.cshtml Run code for each page Setup layout page for an entire folder
  • 13. Using Helper App_Code/RazorHelper.cshtml @helper ShowCopyright() { <div> Copyright Shiju Varghese @DateTime.Now.Year </div> Using a Helper @RazorHelper.ShowCopyright()
  • 14. Demo