مشخصات کتاب
-
Shelter Island
-
2014
-
انگلیسی
-
27232
-
1212
-
221
ASP.NET MVC in Action
دوره آموزش MVC
PART 1 HIGH-SPEED FUNDAMENTALS..............................1
1 Introduction to ASP.NET MVC 3
1.1 Setting the stage 4
The .NET platform 4 ■ ASP.NET Web Forms 5
1.2 What is ASP.NET MVC? 5
The MVC pattern 7 ■ Benefits of ASP.NET MVC 8
1.3 What’s new in ASP.NET MVC 3/4? 8
The Razor view engine 9 ■ Package management with NuGet 9
Improved extensibility 10 ■ Global action filters 10 ■ Dynamic
language features 10 ■ Partial page output caching 10
Ajax improvements 10 ■ Validation improvements 10
2 Hello MVC world 12
2.1 Setting up your development environment 13
Installing MVC using the Web Platform Installer 13
2.2 Creating your first MVC application 15
Creating a new project 15 ■ A tour of the default project template 17
Controllers, actions, and displaying dynamic content 19
2.3 The Guestbook sample application 23
Creating the database 23 ■ Adding the model 24 ■ Accepting
guestbook entries 28 ■ Displaying guestbook entries 33
Customizing the look and feel with layouts 35
2.4 Summary 37
3 View fundamentals 38
3.1 Introducing views 38
Selecting a view to render 39 ■ Overriding the view name 40
3.2 Passing data to views 40
Examining the ViewDataDictionary 40 ■ The ViewBag 42
Strongly typed views with a view model 43 ■ Displaying view model
data in a view 44
3.3 Using strongly typed templates 48
EditorFor and DisplayFor templates 49 ■ Built-in templates 51
Selecting templates 52 ■ Customizing templates 54
3.4 Summary 58
4 Action-packed controllers 59
4.1 Exploring controllers and actions 60
IController and the controller base classes 60 ■ What makes an
action method 62
4.2 What should be in an action method? 63
Manually mapping view models 64 ■ Input validation 66
4.3 Introduction to unit testing 69
Using the provided test project 69 ■ Testing the
GuestbookController 71
PART 2 WORKING WITH ASP.NET MVC......................79
5 View models 81
5.1 What is a view model? 82
The online store example 82 ■ Building the view model 84
Delivering the presentation model 84 ■ ViewData.Model 85
5.2 Representing user input 86
Designing the model 86 ■ Presenting the input model in a
view 87 ■ Working with the submitted input 88
5.3 More complex models for both display and input 89
Designing a combined display and input model 90 ■ Working with
the input model 90
5.4 Summary 91
6 Validation 92
6.1 Server-side validation 93
Validation with Data Annotations 93 ■ Extending the
ModelMetadataProvider 96
6.2 Client-side validation 98
Getting started with client-side validation 99 ■ Using
RemoteAttribute 100 ■ Creating custom client-side validators 101
6.3 Summary 103
7 Ajax in ASP.NET MVC 104
7.1 Ajax with jQuery 105
jQuery primer 106 ■ Using jQuery to make Ajax requests 107
Progressive enhancement 109 ■ Using Ajax to submit form data 111
7.2 ASP.NET MVC Ajax helpers 114
Ajax.ActionLink 116 ■ Ajax.BeginForm 117 ■ Ajax options 118
Differences from earlier versions of ASP.NET MVC 119
7.3 Ajax with JSON and client templates 120
Ajax with JSON 120 ■ Client-side templates 124 ■ Finishing
touches 126
7.4 Creating an autocomplete text box 129
Building the CitiesController 129
7.5 Summary 134
8 Security 135
8.1 Authentication and authorization 136
Restricting access with the AuthorizeAttribute 136
AuthorizeAttribute—how it works 138
8.2 Cross-site scripting (XSS) 140
XSS in action 140 ■ Avoiding XSS vulnerabilities 142
8.3 Cross-site request forgery (XSRF) 145
XSRF in action 146 ■ Preventing XSRF 147 ■ JSON hijacking 149
8.4 Summary 152
9 Controlling URLs with routing 153
9.1 Introducing URL routing 154
The default route 154 ■ Inbound and outbound routing 156
9.2 Designing a URL schema 157
Make simple, clean URLs 157 ■ Make hackable URLs 158
Differentiate requests using URL parameters 159 ■ Avoid
exposing database IDs wherever possible 159 ■ Consider adding
unnecessary information 160
9.3 Implementing routes in ASP.NET MVC 162
URL schema for an online store 162 ■ Adding a custom static
route 162 ■ Adding a custom dynamic route 163 ■ Catch-all
routes 165
9.4 Using the routing system to generate URLs 167
9.5 Routing with ASP.NET Web Forms 169
Adding routes for Web Forms pages 169 ■ Generating URLs from
Web Forms pages 172
9.6 Debugging routes 173
Installing Route Debugger 173 ■ Using Route Debugger 174
Using route constraints 176
9.7 Testing route behavior 178
Testing inbound routes 178 ■ Testing outbound routes 183
9.8 Summary 183
10 Model binders and value providers 185
10.1 Creating a custom model binder 186
10.2 Using custom value providers 191
10.3 Summary 196
11 Mapping with AutoMapper 197
11.1 Life before AutoMapper 198
11.2 Introducing AutoMapper 200
Mapping matching property names 200 ■ Flattening object
hierarchies 201
11.3 AutoMapper basics 202
AutoMapper Initialization 202 ■ AutoMapper profiles 202
Sanity checking 203 ■ Reducing repetitive formatting code 204
Another look at our views 206
11.4 Summary 206
12 Lightweight controllers 207
12.1 Why lightweight controllers? 208
Easy to maintain 208 ■ Easy to test 208 ■ A focused
responsibility 208
12.2 Techniques for simplifying controllers 210
Managing common view data 211 ■ Deriving action results 214
Using an application bus 216
12.3 Summary 219
13 Organization with areas 220
13.1 Creating a basic area 221
13.2 Managing links and URLs with T4MVC 227
13.3 Summary 230
14 Third-party components 232
14.1 Learning about NuGet 233
Updating a package 233 ■ Understanding NuGet basics 235
14.2 Using ASP.NET Web Helpers 237
14.3 The MvcContrib Grid component 240
Using the MvcContrib Grid 240 ■ MvcContrib Grid advanced
usage 241
14.4 Summary 243
15 Data access with NHibernate 244
15.1 Functional overview of reference implementation 245
15.2 Application architecture overview 246
15.3 Exploring the Core 247
15.4 NHibernate configuration–infrastructure of the application 249
NHibernate’s configuration 251 ■ The NHibernate mapping—
simple but powerful 252 ■ Initializing the configuration 253
15.5 Presenting the model through the UI 259
15.6 Pulling it together 262
15.7 Summary 264
PART 3 MASTERING ASP.NET MVC ..........................265
16 Extending the controller 267
16.1 Controller extensibility 268
16.2 Controller actions 268
16.3 Action, authorization, and result filters 269
16.4 Action selectors 271
16.5 Using action results to reduce complexity 272
Removing duplication with an action result 272 ■ Using action
results to abstract hard-to-test dependencies 274
16.6 Summary 275
17 Advanced view techniques 276
17.1 Eliminating duplication in the view 277
Layouts 277 ■ Partials 279 ■ Child actions 281
17.2 Building query-string parameter lists 282
17.3 Exploring the Spark view engine 285
Installing and configuring Spark 286 ■ Simple Spark view
example 287
17.4 Summary 292
18 Dependency injection and extensibility 294
18.1 Introducing dependency injection 295
What is DI 296 ■ Using constructor injection 297 ■ Introducing
interfaces 298 ■ Using a DI container 299
18.2 Using DI with ASP.NET MVC 301
Custom controller factories 302 ■ Using the dependency
resolver 305
18.3 Summary 309
19 Portable areas 311
19.1 NuGet packaging basics 312
A simple area to package 312 ■ Consuming portable areas 314
19.2 Creating an RSS widget with a portable area 315
Creating the RSS widget portable area example 315
19.3 Interacting with the portable area bus 319
Example of using the MvcContrib message bus 319
19.4 Summary 320
20 Full system testing 321
20.1 Testing the UI layer 322
Installing the testing software 322 ■ Walking through the test
manually 323 ■ Automating the test 325 ■ Running the test 327
20.2 Building maintainable navigation 327
20.3 Interacting with forms 331
20.4 Asserting results 334
20.5 Summary 338
21 Hosting ASP.NET MVC applications 339
21.1 Hosting environments 340
21.2 XCOPY deployment 341
21.3 IIS 7 345
21.4 IIS 6 and 5.1 347
21.5 Azure hosting 349
What is Windows Azure, and how do I get it? 350 ■ Configuring
the application for Azure deployment 354 ■ Packaging and
deploying your application 359 ■ Accessing your application
running in Windows Azure 363
21.6 Summary 364
22 Deployment techniques 365
22.1 Employing continuous integration 366
22.2 Enabling push-button XCOPY deployments 367
22.3 Managing environment configurations 368
22.4 Enabling remote server deployments with Web Deploy 370
22.5 Summary 373
23 Upgrading to ASP.NET MVC 4 374
23.1 Runtime view selection with DisplayModes 375
Using the Mobile DisplayMode 375 ■ Creating new DisplayModes 377
Empowering users to override DisplayModes 378
23.2 Combining and minifying client assets 381
23.3 Improvements to Razor 383
Automatic tilde-slash resolution 383 ■ Conditional attributes 383
23.4 Summary 384
24 ASP.NET Web API 385
24.1 What is Web API? 385
Why Web API? 386 ■ How Web API is different from WCF 386
24.2 Adding web services to the Guestbook application 389
Creating a GET web service 390 ■ Creating POST web services 391
24.3 Web API alternative 394
24.4 Summary 396
index 397