The new ASP. net mvc 4 Framework secrets is officially published

Source: Internet
Author: User

I wrote the book ASP. NET MVC 4 Framework secrets ("Bowen Viewpoint" of the Electronic Industry Press) in the last year before the end of the world. Currently, the interactive publishing network has begun to accept reservations.This book is not an introductory book about ASP. NET MVCFor the latest version of ASP. net mvc 4, in-depth analysis of the entire process of the underlying framework from request receipt to response (including URL routing, Controller activation, Model metadata parsing, Model binding, Model validation, Action execution, view rendering and ASP. NET Web API), and on the basis of this guide readers how to through ASP. the extension of the net mvc Framework solves practical problems in application development.

ASP. net mvc is a Web development framework built on the ASP. NET platform based on the MVC pattern. It provides a completely different Web application development method from the traditional Web Form. ASP. NET Web Form draws on the Windows Form programming mode based on controls and event registration, making Web Application Development simple and fast, but it makes the nature of the development staff and Web increasingly far away. ASP. net mvc is a regression that allows developers to actually program to the Web. What we face is no longer the drag to the Web page control, but the entire HTTP request and response process.

This is not an ASP. net mvc entry book

I personally think there are three levels to master ASP. NET MVC. This is the first level to learn about the basic programming mode, how to define the Controller and View, how to register a route, and how to define verification rules. The second layer requires us to apply ASP. net mvc framework has a clear understanding of the entire process from receiving requests to responding to replies, this includes how requests are routed, how the target Controller is activated, how the Model metadata is parsed, how the Action method is executed, and how the View is presented. ASP. net mvc itself is a very scalable development framework. The rational use of its scalability can solve many practical problems in development, and Master ASP. the highest level of net mvc is to find the corresponding extension Points Accurately based on the understanding of the operating mechanism of the framework itself, and create the corresponding extensions to solve our problems. This book is not an ASP. net mvc entry book, but a book that allows readers at the first level to quickly enter the second and third levels.

This is a book describing the essence of ASP. net mvc framework.

Many. NET developers complain that the too-fast update frequency of Microsoft development technology makes them at a loss. In fact, they only see version upgrades. Some essential things have always been "stable. Microsoft has launched the. NET strategy for more than a decade, but only four CLR versions are available. Although ASP. NET of the latest version does not have much initial shadows on the surface, the pipeline of the entire request processing has never changed. For a development technology, as long as we understand some of its most fundamental things, we should not fear its high-frequency version replacement, but embrace it enthusiastically. This book strives to bring the most fundamental things about the ASP. net mvc Framework to everyone, rather than listing some simple programming skills.

This is a practical book.

Some people may think that this article analyzes ASP. net mvc framework operating principles book has no "practical" meaning, because our daily work is programming, understand ASP. net mvc's entire process from request receipt to response does not substantially change our work. In fact, this idea is extremely wrong, because the program we write is ultimately in ASP. net mvc Framework, the program's efficiency depends on whether it can "cater to" the operating mechanism of the framework to the maximum extent, so understand ASP. the operating principle of the net mvc framework is conducive to writing high-quality programs.

I personally divided ASP. NET MVC-based programming into two categories: "business-oriented programming" and "framework-oriented programming ". The former defines Controller and design View based on specific business logic, which is the main work of most Web developers. The latter sets up a framework for the entire Web application, let the end developer focus only on the specific business logic, and let the framework complete all the business-independent parts. For the latter, we can make full use of ASP.. net mvc scalability. Custom extensions are used to automatically inject non-business functions into the processing process of business logic. This not only improves the development efficiency, but also improves the development quality. This book lists almost all of its extension points in the process of analyzing the ASP. net mvc framework operating mechanism, and provides many practical extensions through instance demonstration.

This book can be regarded as a "Architectural Design" book

There are people like this around me who have just graduated for a year or two. Most of them work diligently and learn smartly. They often hold GoF's design patterns in their hands and always hope to apply the design patterns in the books to specific projects, or they want to prove their design patterns in books through project practice, but the distance between theory and practice is always confusing to them.

To learn "practical" software architecture design knowledge from a real project or product, you must first determine the architecture ideas and design patterns used in the target project or product, many of the projects we participated in were actually "architecture" in a mess. For ASP. the infrastructure of a product such as NET can remain unchanged for a long time, which proves the correctness of the above architecture design, aren't they the best materials for us to learn about architecture design? This book describes ASP. the operating mechanism of the net mvc framework is deeply analyzed. the entire design of net mvc is presented to readers. Readers may be able to read this book as a "Architectural Design" book.

Writing Features of this book

I think many readers of this book may have read my comprehensive analysis on WCF. Although the content is different, this book may be regarded as a continuation because they basically adopt the same writing method. In general, I basically use the "principles, code analysis, and instance proof" mode to introduce a technical point. For a specific knowledge point, I will not only tell the reader what it is ", it will also tell the reader "why" and "how to prove it ". In addition, if a knowledge point has "practical" value in real project development, I will generally give a demo of the related instance.

This book has a completely different feature from other Chinese original or translated books, that is, almost all terms use English, for example, Controller, Model, and View are not translated into Chinese "controllers", "models", and "views ". I think it is difficult for many terms to find a Chinese phrase or phrase with exactly the same semantics. for readers who are used to English as a "development language, forced translation is not necessary.

This is not a purely theoretical book, but an "empirical" book that provides 110 examples for separate download. These examples play a different role in this book. Some are used to detect and prove the corresponding arguments, some are used to demonstrate some programming skills, and some are directly a complete case.

Readers of this book

Let's talk about ASP. net mvc Framework secrets, not an ASP. net mvc entry-level books, mainly because the book does not provide a "Hello World" instance in Chapter 1. The focus of this book is mainly on ASP. net mvc framework, but it does not mean that readers of this book need to advance ASP. net mvc has a deep understanding. If you have a certain understanding of the basic programming modes of ASP. net mvc, there is no problem in reading this book. For. NET developers who have never been familiar with ASP. net mvc, they can learn ASP. net mvc through the official website (

Chapter 1 ASP. NET + MVC 1
1.1. Traditional MVC Mode 2
1.1.1. Autonomy view 2
1.1.2. What is the MVC mode? 2
1.2. MVC Variant 4
1.2.1. MVP 4
1.2.2. Model 2 11
1.2.3. ASP. net mvc and Model 2 12
1.3. IIS/ASP. NET pipeline 13
1.3.1. IIS 5.x and ASP. NET 13
1.3.2. IIS 6.0 and ASP. NET 14
1.3.3. IIS 7.0 and ASP. NET 16
1.3.4. ASP. NET MPs queue 19
1.4. How does ASP. net mvc run? 23
1.4.1. Web application built on "mini version" ASP. net mvc 23
1.4.2. URL routing 25
1.4.3. Controller activation 29
1.4.4. Execution of Action 32
Chapter 36
Chapter 3 URL routing 37
2.1. ASP. NET routing system 38
2.1.1. Separation of request URLs and physical files 38
2.1.2. instance Demonstration: implement the ing between the request address and the. aspx page (S201) 38 through URL Routing
2.1.3. Route and RouteTable 41
2.1.4. Route ing 46
2.1.5. Generate URL 54 based on routing rules
2.2 ASP. net mvc extension 55
2.2.1. Route ing 55
2.2.2. Example: Register route ing and view route information (S208) 57
2.2.3. Default URL parameter 59
2.2.4. Area-based route ing 60
2.2.5. Generate links and URLs 65
2.3. Dynamic HttpHandler ing 70
2.3.1. UrlRoutingModule 71
2.3.2. PageRouteHandler and MvcRouteHandler 72
2.3.3. ASP. NET route System Extension 73
Chapter 77
Chapter 2 Controller activation 78
3.1. Overall Design 79
3.1.1. Controller 79
3.1.2. ControllerFactory 83
3.1.3. ControllerBuilder 85
3.1.4. Controller activation and URL routing 90
3.2. The default value is 92.
3.2.1. Controller type parsing 92
3.2.2. Controller-type cache 95
3.2.3. Controller release and session Status Control 96
3.3. IoC application 97
3.3.1. Understanding IoC 98 from Unity
3.3.2. Separation of Controller and Model 100
3.3.3. IoC-based ControllerFactory 101
3.3.4. IoC-based ControllerActivator 106
3.3.5. IoC-based DependencyResolver 107
Summary 110
Chapter 4 Analysis of Model metadata 4th
4.1. Model metadata and customization 112
4.1.1. Hierarchical Structure of Model metadata 112
4.1.2. Basic Model metadata 113
4.1.3. Custom Model metadata 116
4.1.4. IMetadataAware API 128
4.2. Model metadata and Model template 132
4.2.1. instance Demonstration: use the template to display the Boolean value as RadioButton (S409) 133
4.2.2. predefined template 134
4.2.3. DataTypeName and Template Name 142
4.2.4. template acquisition and execution 145
4.2.5. Example demonstration: display the predefined list by customizing the Model metadata and custom templates (S412) 148
4.3. mechanism for providing Model metadata 155
4.3.1. Let's talk about ModelMetadata 156.
4.3.2. ModelMetadataProvider 159
4.3.3. Model metadata provides System Extension 163
Summary 164
Chapter 4 Model binding 5th
5.1. ControllerDescriptor, ActionDescriptor, and ParameterDescriptor 167
5.1.1. ControllerDescriptor 167
5.1.2. ActionDescriptor 171
5.1.3. ParameterDescriptor 175
5.2. ValueProvider 177
5.2.1. NameValueCollectionValueProvider 178
5.2.2. DictionaryValueProvider 184
5.2.3. ValueProviderFactory 190
5.2.4. ValueProviderFactories 191
5.3. ModelBinder 194
5.3.1. ModelBinder and ModelBinderProvider 194
5.3.2. Bind ModelState to Model 201
5.3.3. Create ModelBindingContext 205
5.4. default Model binding implementation 206
5.4.1. Simple Type 206
5.4.2. Complex Type 210
5.4.3. arrays 215
5.4.4. Set 222
5.4.5. The dictionary is 224
Summary 228
Chapter 1 Model verification 6th
6.1. ModelValidator and ModelValidatorProvider 230
6.1.1. ModelValidator 230
6.1.2. ModelValidatorProvider 233
6.1.3. ModelValidatorProviders 237
6.2. Model binding and verification 242
6.2.1. ModelState 242
6.2.2. Verify message rendering 245
6.2.3. Verification 251 in Model binding
6.3. Model Verification Based on Data annotation features 255
6.3.1. ValidationAttribute feature 255
6.3.2. DataAnnotationsModelValidator 261
6.3.3. DataAnnotationsModelValidatorProvider 263
6.3.4. Apply ValidationAttribute to parameters 266
6.3.5. One Model type and multiple verification rules 271
6.4. Client verification 277
6.4.1. jQuery verification 277
6.4.2. jQuery-based Model verification 281
6.4.3. Custom verification 284
Summary 287
Chapter 2 Action execution 7th
7.1. Definition of asynchronous Action 289
7.1.1. Thread Pool-based request processing mechanism 289
7.1.2. Definitions of the two asynchronous Action methods 290
7.1.3. AsyncManager 292
7.2. Execution of the Action Method 297
7.2.1. MvcHandler processes the request 297
7.2.2. Controller execution 297
7.2.3. ActionInvoker execution 298
7.2.4. synchronous and asynchronous 302 of ControllerDescriptor
7.2.5. ActionDescriptor execution 305
7.3. Filter execution 311
7.3.1. Filter and Its provision mechanism 311
7.3.2. AuthorizationFilter 319
7.3.3. ActionFilter 328
7.3.4. ExceptionFilter 333
7.3.5. Example: integrated with EntLib for automatic Exception Handling (S713, S714, S715) 335
7.3.6. ResultFilter 348
Summary 349
Chapter 2 View presentation 8th
8.1. ActionResult 351
8.1.1. EmptyResult 351
8.1.2. ContentResult 352
8.1.3. FileResult 357
8.1.4. JavaScriptResult 361
8.1.5. JsonResult 364
8.1.6. Http statuscoderesult 366
8.1.7. RedirectResult/RedirectToRouteResult 367
8.2. ViewResult and ViewEngine 369
8.2.1 View 369 in the View Engine
8.2.2. View engine 370
8.2.3. ViewResult execution 373
8.3. Razor engine 379
8.3.1. View Compilation Principle 380
8.3.2. WebViewPage and WebViewPage <TModel> 384
8.3.3. Raid view 387
8.3.4. RazorViewEngine 395
Summary 399
Chapter 2 ASP. NET Web API 9th
9.1. Web, REST, and Web API 401
9.1.1. Web is so simple 401
9.1.2. What is REST? 402
9.1.3. ASP. NET Web API 404
9.2. Server MPs queue 412
9.2.1. ASP. NET Web API Pipeline Design 413
9.2.2. httpmessagehandller 414
9.2.3. HTTP server 417
9.2.4. Example: Custom HttpMessageHandler implements HTTP Method rewriting (S903) 422
9.3. HttpControllerDispatcher 423
9.3.1. HttpController activation 424
9.3.2. HttpController execution 435
9.3.3. Select 436 for Action
9.3.4. parsing of Model metadata 442
9.3.5. Bind the Action parameter to 444
9.3.6. Model Verification 456
9.3.7. Action execution and response 460
9.4. Web API call and self-hosting 463
9.4.1. HTTP client 463
9.4.2. httpselfhost server 468
Summary 471
Chapter 2 case practice 10th
10.1. Functional introduction 474
10.1.1. display of product list 474
10.1.2. Order product 475
10.1.3. logon and error page 476
10.2. design overview 477
10.2.1. Controller-Service-Repository 477
10.2.2. IoC application 481
10.2.3. Application of AOP 483
10.2.4. Handling exceptions 489
10.3. Programming implementation 490
10.3.1. Create a data table 490
10.3.2. Repository 491
10.3.3. Service 495
10.3.4. Route registration and layout 498
10.3.5. ProductController 500
10.3.6. Order Controller 507
10.3.7. AccountController 512
Summary 515
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.