11. Building NuGet Package
• Authoring support
• Define dependencies
• Transform configuration file and source
• Add initialization to web app startup via WebActivator
• Contribute at http://nuget.org/Contribute/Index
15. Basic Syntax
Razor ASPX Description
@exp <%: exp %> Encode and output an expression to the page
@(exp) <%: exp %> Explicit expression, e.g. @(imagePath).jpg
@{ stms; } <% stms; %> Execute code statements
@Html.Raw(exp) <%= exp %> Output an expression to the page
@* cmt *@ <%-- cmt --%> Comment out code block
@if(cond) { <% Execute conditional statements
stm; if (cond) {
} else { stms; Other constructs work the same way: @foreach,
stms; } else {
@for, @while, @switch, @try etc.
} stms;
}
%>
16. Transition to Code
• As soon as Razor parser encounters the syntax mentioned in
Basic Syntax, it switches to code mode
• Escape @ by using @@, e.g. Tweets by @@buunguyen
17. Transition to Markup
Option 1:
HTML Block
Option 2:
Text Block
Option 3:
Single line markup
35. Model Validation
[Required] • A value must be provided
[Range] • Value must be in a given range e.g. 1-10
[RegularExpression] • Value must satisfy a regular expression
[StringLength] • Value must be a min length and less than the max length
[Compare] • Value must equal another property e.g. password
[Remote] • Value is validated remotely via JSON
Extensible… • Custom model validators
36. Other Validation Improvements
• Self-validating model with IValidatableObject
• ValidationContext for multi-property validation
• Client-validation is enabled by default
• jQuery Validate plugin is used by default
• Unobtrusive client-side validation
• EF4 CTP5 works with validation attributes