Models: Data and business logic
View: Show
Controller: Receive view input data and return to the view after processing by the model layer business logic
Separation of concerns (Model View Controller), customary precedence principle
Browser-->routing-->controller<--view-->browser
The controller tells the next step what to do instead of what to do, such as displaying the view and returning Actionresults.
Locate the view: first find the corresponding folder, second find shared folder
Razor: Code snippets, code blocks
Partial views @Html. Partial (), Partialview () can be returned to Axaj
Controller passes data to view: ViewData and viewbage (dynamic)
View Model: Viewdata.model strongly typed attempt: @model type
HtmlHelper: @Html Generate Html
Urlhelper: @Url Generate URL
Data model, domain model
Web Form and Background Web Components (ASP)
HTTP is stateless: ASP. NET is view state
-
Basic differences
ASP. |
MVC |
View logic combines /td> |
detach |
page URL based on file access |
There is a routing URL lookup controller |
|
No automation view Management |
web form syntax |
razor syntax |
server control |
html Help method |
motherboard |
layout |
user control |
partial view |
can use routing, but MVC cannot do without, the web from is to optimize
HTMLHelp can create his own method.
Object Relational Mapping Framework ORM (Object Relational mapping)
Entity Framework:code-first, Model-first, Database-first.
Model data Validation System.ComponentModel.DataAnnotations ()
[System.ComponentModel.DataAnnotations.Range (typeof (DateTime), "2010-01-01", "2015-02-02", errormessage= "missed")]
Customizable validation methods
Code-first:system.data.entity.dbcontext connection string key is the same as the base class name: ConnectionStrings
Ajax:xmlhttprequest Object First open (set to Async and callback function) after send to Judge Status==200 and readystate==4
MVC turns on client-side validation
Controllers: Block user input, reconcile models and views, and their communications
Models: Data attributes, data validation, business logic
Views: Rendering UI, binding model
Check input data before sending to another layer
Single Responsibility principle (SRP), open closure principle (OCP open for expansion, modification off), Richter replacement principle (LSP), interface isolation principle (ISP), dependency inversion principle (DIP)
control Inversion : Dependency Injection and service positioning http://www.cnblogs.com/tylerdonet/p/3297915.html
Actionfilter
Client templates: Mustache.js
Operation Filter: Implement the processing before and after the request, marking method
Model Binder
Jsonp implementing cross-domain AJAX requests
The Web API uses the Routetable.maphttproute ()
Web API name Precedence GET PUT POST DELETE
ODATA: Open Data Protocol CRUD
Httpresponseexception in the Web API, you can use exception filters, global registrations or attribute annotations, overriding
Media Formatter: Global registration after creation, can serialize MIME type in accept
Rest Full style:
Get/tickets # Get Ticket list
GET/TICKETS/12 # View a specific ticket
Post/tickets # Create a new ticket
PUT/TICKETS/12 # Update Ticket 12.
DELETE/TICKETS/12 #删除ticekt 12
Poco plain old CLR object, representing business entity Class model, focus on business No database structure required
Repository Mode: Resource library, warehousing database access mode, responsible for the persistent application business model, there are one, aggregate root, generics a-to-many
Reference type: = = Reference equals value
MVC Defense CSRF: Use @html.antiforgerytoken (), and then mark on the method.
JQuery.Mobile.MVC nuget Development Mobile version, modify bundles
Mobile version: in action.mobile.cshtml format
_viewswitcher partial views can be switched between mobile and PC versions
Viewport Setting the screen rotation width issue
51degrees to enhance the setting
Asynccontroller Asynchronous Controller
Routing order is important
Asynchronous operations are primarily used for I/O binding operations (such as database access and remote service invocation), with 2 methods implemented asynchronously
*async/*completed
Public task<*> M () {return}
AsyncManager.OutstandingOperations.Decrement ();
WebSocket
SignalR: Hubs and permanent connections
Server-Side Caching (
Cache Httpcontext.items in the request domain
Session (can be stored externally)
Application is managed by IIS at the application level and can span processes
System.Web.Cache ( cache dependency policy )
Http://www.cnblogs.com/kissdodog/archive/2013/05/07/3064895.html
Client-Side Caching
MVC markup Outputcacheattribute property implements HTML page caching
Configurable cache time, location (browser or service side)
The VaryByParam property is only valid if the parameter is
Can be configured in Web. config using profiles
This represents the extended String class public static int WordCount (this string str)
Donut cache: WriteSubstitution can be partially not cached
Mvcdonutcachingnuget Packages Enable advanced operations
The Web farm is a physically separate server cluster, and the Web garden refers to the application pool that contains multiple worker processes
AppFabric, Memcached, Redis
HTML5 cache: Appcache,js Local storage
Yslow Detecting Web Performance
The shorter the URL, the better, the dashes instead of underscores, the use of lowercase letters
The MVC route parameter is separated by a constant string {P1}-{P2}-{P3}, and the parameter defaults to string type
Route wildcard {Controller}/{action}/{*queryvalues}, the string following the controller operation counts as the value of the last parameter
Denies all aspx request parameter allaspx:routes. Ignoreroute ("{*allaspx}", new {[email protected] ". *\.aspx (/.*)?"});
Routing constraints can be set through regular expressions
Customizable route constraint methods
Observing routes using glimpse
can implement attribute tag-based routing
Razor Single File Generator
Renderaction ()
Controller operation exception handling, can be globally registered [HandleError (exceptiontype=typeof (System.Data.DataException), view= "Databaseerror")]
Overriding the controller Onexception () method to implement exception handling
Custom Error Filters
Asp. NET health Monitoring
Unit Test (class or method) "autonomous, repeatable, independent, fast"
Integration testing (testing interactions between multiple components)
Acceptance testing (to meet the requirements)
Test-driven Development (TDD) red-green-refactor
TestInitialize () initializing common test parameters
Analog test frameworks such as the MOQ framework
Automated Browser Test Watin
Code coverage 100 lines tested for 70 rows
Automating the generation of Microsoft MSBuild and TeamFoundation Server
Martin Fowler's Books: 1. Analysis mode 2.UML Essence 3. Refactoring 4. Enterprise Application Architecture Model 5.Nosql Essence
Windows Azure
NuGet
Https://npe.codeplex.com/releases/clickOnce/NuGetPackageExplorer.application
http://kb.cnblogs.com/page/143191/
Https://www.nuget.org/account/Packages