-
Rout
- URL
-
Routing
- routes.MapRoute
- parameter
- Variable-Length
- Namespace
-
Constraining
- Regular Expression
- Specific Values
- Using HTTP Methods
- Custom Constraint
- Disk Files
- Bypassing the Routing System
- Area (Module)
-
Controller
- Filter
- Custom Controller Factory
- Handling Unknown Actions
- Sessionless Controllers
-
Asynchronous Controllers
- IAsyncController
-
AsyncController,
- <Action>Async
-
<Action>Completed
- 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.
-
provider
-
Membership,
- SqlMembershipProvider)
- ActiveDirectoryMembershipProvider).
- Oracle,
- NHibernate,
- XML
- Roles,
-
Profiles,
- anonymousIdentification=true
- Explained: Forms Authentication in ASP.NET 2.0
-
Build-in Objects
-
IController
-
Controller
-
Action methods:
- ActionResult
- ViewResult
- PartialViewResult
- RedirectToRouteResult
- RedirectResult
- ContentResult
- FileResult
- JsonResult
- JavaScriptResult
- HttpUnauthorizedResult
- HttpNotFoundResult
- HttpStatusCodeResult
- EmptyResult
- Action results:
- Filters:
- IPrincipal (User)
- ViewBag
-
ViewData
- ModelState (ModelStateDictionary)
-
View function
- return
- ViewResult
- View
- TempData
- ViewBag
- ViewData type of ViewDataDictionary
- Model
- TemplateInfo
- FormattedModelValue
- GetFullHtmlFieldId()
- GetFullHmlFieldName()
- HtmlFieldPrefix
- ModelMetadata
- AdditionalValues
- IEnumerable<ModelMetadata> Properties
- ModelState
-
Input
- from function parameters
- RequestContext same same as ControllerContext
- RouteData
- "Controller"
- "action"
- ...
- Route (RouteBase)
- Values (RouteValueDictionary)
- HttpContext
- Request
- QueryString
- Form
- Cookies
- HttpMethod
- Headers
- Url
- UserHostAddress
- File
- IsAjaxRequest())
- Response
- Application
- Cache
- Items
- Session
- invoke model binding
- ModelState
-
View
-
ModelMetadata
- DataTypeName
- DisplayFormatString
- DisplayName
- EditFormatString
- HideSurroundingHtml
- Model
- NullDisplayText
- ShowForDisplay
- ShowForEdit
- TemplateHint
- funcion AdditionalValues
-
ModelMetadataProvider
-
DataAnnotationsModelMetadataProvider
- Localization With ASP.NET MVC
-
Filter
-
Authorization
-
IAuthorizationFilter
- AuthorizationContext
- Controller
- HttpContext
- IsChildAction
- RequestContext
- RouteData
- Built-in Authorization Filter
- Users
- Roles
- Result
-
Exception
-
IExceptionFilter
- ExceptionContext
- ActionDescriptor
- Result
- Exception
- ExceptionHandled
- Using Global Filters
-
Built-in Filters
- RequireHttps
- OutputCache
- ValidateInput
- ValidationAntiForgeryToken
- AsyncTimeout
- NoAsyncTimeout
- ChildActionOnlyAttribute
- HttpPost
- NonAction]
- Action
- IActionFilter
- IAuthorizationFilter
- IExceptionFilter
- IResultFilter
-
Unobtrusive Ajax
-
Form
-
ajax option
- Confirm
- HttpMethod
- InsertionMode
- LoadingElementId
- LoadingElementDuration
- UpdateTargetId
- Url
- Ajax Link
- Working with JSON