Passing Parameters from the Async to the Completed Method
timeout
set time out
[AsyncTimeout(10000)]
[NoAsyncTimeout]
handle timeout exception
Aborting Asynchronous Operations
AsyncManager.Finish
Model
Mode template
@Html.DisplayFor
Display
Editor
EditorFor
Label
LabelFor
DisplayText
For model
DisplayForModel
EditorForModel
LabelForModel
Using Model Metadata
[HiddenInput]
[HiddenInput(DisplayValue=false)]
[ScaffoldColumn(false)]
[Display(Name="Date of Birth")]
[DataType(DataType.Date)]
DateTime
Date
Time
Text
MultilineText
Password
Url
EmailAddress
Custom Editor Template
DisplayTemplates
EditorTemplates
UIHint
Replacing the Built-in Templates
DataAnnotationsModelMetadataProvider
Model Binding
IModelBinder
DefaultModelBinder.
Data come from
Request.Form
RouteData.Values
Request.QueryString
Request.Files
Simple type
default prefix
select prefix
Selectively Binding Properties
Exclude properties
array
Dictionary
Invoking Model Binding
select data source for binding
FormCollectionData
FileUploadBinding
Customizing the Model Binding System
IValueProvider
Model Validation
Build-in
Explicitly Validating a Model
ModeState.AddModelError
Validation Rules Using Metadata
Custom Property Validation Attribute
build-in attribute
Required
RegularExpression
Range
Compare
StringLength
Self-validating Model
inherit
IValidatableObject
Model Validation Attribute
Alternative Validation Techniques
Model Binder
inherit DefaultModelBinder
ModelBinders.Binders.Add
Custom Validation Provider
inherit
ModelValidatorProvider
return
return list of ModelValidator base on ContainerType or Model Type
ModelValidator
return list of
ModelValidationResult
PropertyValidator same as ModeValidator
properties
PropertyName
ContainerType
ModelType
ModelValidator
for
Model
override
Validate
add ModelValidationResult[] to error list
Property
override
Validate
return list of ModelValidationResult
ModelValidationResult
register on global
Client side
Client-Side Validation
enable/disable
web.config
global
override on view
Customizing
add more in view
Required
Length
Range
Regex
Equalto
Email
Url
Date
Number
Digits
Creditcard
Model Attributes That Support Client-Side Validation
inherit
IClientValidatable
example
Subtopic 2
Write javascript
javascript
server side
Remote Validation
display error message on view
View
Ajax
Unobtrusive
jQuery
Knockout
engine
IViewEngine
ViewEngineResult
IView
ViewEngineResult
HTML Helpers
Inline HTML Helper
External Helper Method
Built-in HTML Helpers
Creating Forms
Checkbox
Hidden field
Radio button
Password
Text area
Text box
Strong type
Drop-down list
Multiple-select
link
Url.Content
Html.ActionLink
Url.Action
Html.RouteLink(
WebGrid Helper
Crypto
WebMail
Json
ServerInfo
WebImage
@Sections
------------>
@RenderSection("Header")
Partial Views
@Html.Partial("MyPartial")
Child Actions
ChildActionOnly]
return PartialView(
Rendering a Child Action
@Html.Action("Time")
Security
Hack
Authentication & Authorization
Forms Authentication
cookie
FormsAuthentication.Decrypt return
FormsAuthenticationTicket
Name
CookiePath
Expiration
Expired
IsPersistent
IssueDate
UserData (string)
Version
Setting Up
config properties
name
timeout
slidingExpiration
domain
path
loginUrl
cookieless
requireSSL
Handling Login Attempts
1. Display a login prompt.
2. Receive a login attempt.
3. Validate the incoming credentials.
4. If the credentials are valid, call FormsAuthentication.SetAuthCookie(), which will give the
visitor an authentication cookie. Then, redirect the visitor away from the login page.
5. If the credentials are invalid, redisplay the login screen with a suitable error message.