Razor, Routing and Helpers
Razor, Routing and Helpers
Razor
• A markup syntax to create dynamic web pages.
• Introduced with ASP.NET MVC 3.
• Embed with .NET languages C# and VB.
<!-- Single statement block --> <!-- Loop -->
@{ var msg = "Hello World"; } @for(int i = 1; i <= 20; i++)
<!-- Inline expression or variable --> {
<p>My message is: @msg</p> <p>Line @i</p>
}
<!– if Statement -->
@if(flag==true) {
<p>Hi</p>
}
Routing
• A pattern matching system that monitor the incoming request
and figure out what to do with that request.
• Matches the incoming request against a set of endpoints and
their criteria. Typically, a way to serve user request.
• Supports Link/URL generation for registered routes.
Request
Routing
Controller Model
Response
View
Request Handling
Routing System
Endpoint1 Url Pattern
Endpoint2 Url Pattern
Endpoint3 Url Pattern
Route Table
Types of Routing
Convention Routing Configuration & Mapping