Index

caching data, 76 A CDNs (Content Delivery Networks), 76–77 Accept-Language HTTP header, 465, 469 controller class in BLL, 74–75 Access database, as data store, 66 DAL (data access layer), 67 accessibility data store selection, 66–67 selling products online and, 377 Design section, 64–83 site design process and, 48 exception handling and, 77–78 use of tables and, 40–41 JavaScript integration, 82–83 account box settings, 134 layered approach to, 64–65 accounts, managing user accounts, 86 LINQ Entity Framework, 72 actions, controller, 31–32, 175 LINQ impact on DAL, 69–71 AddOption action, opinion poll controllers, 273 LINQ-to-SQL and, 71–72 AddShoppingCartItem action, e-commerce multiple data store support, 67–69 controllers, 401–402 MVC framework and, 64 administration output options and, 78 e-commerce store. See storefront administration presentation layer best practices, 80 views Problem section, 63–64 newsletter, 296 search engine optimization, 81–82 administration console, for polls module, 257 securing DAL, 72–74 administration pages, tools for creating, 89 security and, 75 administrators Solution section, 83 managing user accounts, 86 summary, 83 role, 176 transaction management, 78 AdminProductItem.ascx control user interface, 79 ManageProducts.aspx view, 434–435 views and, 80–81 ViewDepartment.aspx views, 440–441 web.config configuration, 78–79 AdminSidebar.ascx control archiving opinion polls, 258 forum views, 350–351 Article class, 166–168 news, articles, and blog views, 222 extending LINQ objects, 187–188 opinion poll views, 280 methods, 167–168 Adobe Photoshop, site mockup with, 35 overview of, 166 advertising properties, 166–167 newsletters and, 296 article item view user control, 172–173 opinion polls and, 255 ArticleItem.ascx control, 231–233 as revenue option, 375COPYRIGHTEDarticles MATERIAL AJAX approved status for contributors, 153 default files in project creation and, 23 ArticleItem.ascx control, 231–233 extension methods, 29 CreateArticle action, 207–209 MVC applications and, 83 CreateArticles.aspx view, 235–241 UpdatePanel, 307 EditArticle action, 209–211 ALL (application logic layer), 65 extension method queries, 163–164 anonymous users, support for, 106–107 images included in, 172 Apple , 34 Index action for displaying published, 199–201 application logic layer (ALL), 65 ManageArticle action, 205–206 application settings, ASP.NET Web-based ManageArticles.aspx view, 233–235 administration tools for, 107 RateArticle action, 204–205 architecture, planning rating, 249–250 BLL (business logic layer), 74 RemoveArticle action, 212–213

10950bindex.indd 503 5/13/09 4:51:07 PM articles (continued)

articles (continued) Problem section, 1–2 RemoveArticles.aspx view, 241–242 Solution section, 4–5 securing the viewing of, 191–192 summary, 5 ViewArticle action, 202–204 BLL (business logic layer), 74–79 writing with WYSIWYG editor, 171–172 caching data, 76 articles table CDNs (Content Delivery Networks), 76–77 article content information in, 157–159 controller class in, 74–75 LINQ-to-SQL schema and, 180 exception handling and, 77–78 ASP.NET layered design and, 65 tools for creating login and administration pages, 89 output options and, 78 tools for managing users, 107–108 overview of, 74 ASP.NET MVC, introduction to security and, 75 ASP.NET Web Forms compared with, 10–11 transaction management, 78 choosing between ASP.NET Web Forms and ASP.NET web.config configuration, 78–79 MVC, 12–13 breadcrumbs, as navigational hints, 33 controller, 30–32 business logic layer. See BLL (business logic layer) creating first project, 19–25 ByDepartment query, LINQ queries for e-commerce installing, 17–19 store, 397 installing prerequisite software, 13–17 model, 25–26 MVC pattern defined, 9–10 C overview of MVC pattern, 7–9 C# 3.0 prerequisites for, 13 synchronizing access to shared resources, 304–306 strengths/weaknesses, 11–12 syntax for getters and setters, 191 summary, 32 caching data, 76 view, 26–29 CAs (certificate authorities), 377–378 ASP.NET Web Forms Cascading Style Sheets. See CSS (Cascading ASP.NET MVC compared to, 10–11 Style Sheets) choosing between ASP.NET Web Forms and ASP.NET catalogs, of online products, 376 MVC, 12–13 categories MVC view objects inheriting from, 27–28 forums supporting, 328 strengths/weaknesses, 10–11 of products in online store, 376 categories, in article, news, and blog management content syndication with, 151–152 category extension method queries, 164–165 producing/consuming Atom feeds, 173–174 CategoryIndex actions, 201–202 syndication view, 251–253 CategoryIndex.aspx view, 246 attach method, for database deployment, 479–483 CategoryItem.ascx control, 220–222 Atwood, Jeff, 8 CreateCategory action, 213–214 authentication CreateCategory.aspx view, 225–229 distributed authentication system, 88 EditCategory action, 214–215 membership used for, 89–93 ManageCategories.aspx view, 222–225 Windows vs. Forms based, 88 RemoveCategory action, 216–217 authorization RemoveCategory.aspx view, 229–231 defined, 86 categories table roles, 100–102 article category information in, 156–157 Authorize method, MVC security and, 103 LINQ-to-SQL schema and, 181 Category class, 168 CDNs (Content Delivery Networks), 76–77 B certificate authorities (CAs), 377–378 background threads, 302–306 ChangePassword action method, membership system backup and maintenance plan, site deployment and, controller action, 123–124 483–486 ChangePassword.aspx view, membership system TheBeerHouse project views, 138–139 Design section, 2–3 Cheapest query, LINQ queries for e-commerce overview of, 1 store, 395

504

10950bindex.indd 504 5/13/09 4:51:07 PM controllers

ClosePost action, forum controller actions, 349–350 content CMS (Content Management System), 85 email notification when adding new content to code behind websites, 295 code-behind page for sharing behaviors, 49 important features of content-based sites, 3 HTML model in ASP.NET 1.x, 36 Content Delivery Networks (CDNs), 76–77 coding, declarative vs. imperative, 176 Content Management System (CMS), 85 collections content pages IEnumerable class and, 165 accessing master page from, 44–45 paging through, 189–191 editing and effect on master pages, 43 transparent collection enumerator, 191–192 inheriting from master pages, 42 colors, best practices for presentation layer, 80 ContentPlaceHolder control, 42–43 Comment class, 168–170, 189 contributors role, articles and, 176 comments, in news, articles, and blog management controller classes adding, 250–251 in BLL, 74–75 CommentItem.ascx control, 242–243 output options and, 78 CreateComment action, 217–218 controller factory, 31 EditComment action, 218–219 controllers, 30–32 editing, 245–246 actions, methods, results, filters, and selectors, ManageComments.aspx view, 243–246 31–32 RemoveComment action, 219–220 in Atwood’s example, 9 removing, 244–245 author’s definition, 9 sorting, 169–170 controller class in BLL, 74–75 comments table controller factory, 31 feedback on published articles, 159 default controllers created during project creation, 22 LINQ-to-SQL schema, 181 localization of, 475–476 commerce.js overview of, 30 for departments, 428 Reenskaug’s definition of, 8 for products, 435–436 securing actions of, 103–104 for shipping carts, 446 URL routes and, 30–31 for shipping methods, 437–438 controllers, e-commerce store CommerceSidebar.ascx control, storefront AddShoppingCartItem action, 401–402 administration views, 423 CompleteOrder action, 403–408 communication CreateDepartment action, 409–411 important features of content-based sites, 3 CreateProduct action, 414–415 uses of opinion polls, 255 CreateShipping action, 420–421 community, building site community, 327 DeleteProduct action, 417 CompleteOrder action, e-commerce controllers, DeleteShipping action, 421 403–408 DeleteShoppingCartItem action, 402–403 CompleteOrder.aspx view designing, 387–389 designing e-commerce views, 386 EditDepartment action, 411–412 order processing views, 451 EditProduct action, 415–417 configuration module, for e-commerce store implementing, 397 designing, 384 Index action, 398 implementing, 392–393 ManageDepartments action, 409 configuration module, for news, articles, and blogs ManageOrders action, 418 designing, 161 ManageProducts action, 413 implementing, 176–177 ManageShipping action, 420 configuration module, for newsletters ManageStore action, 408–409 configuring web.config, 310 OrderDetail action, 418–420 designing, 307–308 overview of, 397 configuration module, for opinion polls ViewDepartment action, 398–399 designing, 260 ViewProduct action, 399 implementing, 263–264 ViewShoppingCart action, 399–400 configuration module, forums controllers, forum designing, 330 ClosePost action, 349–350 implementing, 333 CreateForum action, 342–343

505

10950bindex.indd 505 5/13/09 4:51:07 PM controllers (continued)

controllers, forum (continued) CreatePoll action, 269–270 CreatePost action, 346–349 designing, 262 designing, 332 EditOption action, 273–274 EditForum action, 343–345 EditPoll action, 270–271 implementing, 336 implementing, 266 Index action, 337 Index action, 266–267 ManageForums action, 341 ManagePolls action, 268–269 ManagePosts action, 342 RemoveOption action, 274 RemoveForum action, 345–346 RemovePoll action, 271–272 RemovePost action, 350 SetArchived action, 275 ViewForum action, 337–338 SetCurrent action, 274–275 ViewPost action, 338–339 Vote action, 267–268 Vote action, 340–341 cookies, handling multiple votes in opinion controllers, membership system polling, 258–259 ChangePassword action method, 123–124 CPUs, multi-threading and, 303 CreateRole action method, 129 CreateArticle action, news, articles, and blog DeleteRole action method, 129–130 controllers, 207–209 DeleteUser action method, 127 CreateArticles.aspx view, 171, 235–241 designing, 111–112 CreateCategory action, news, articles, and blog EditUser action method, 127–129 controllers, 213–214 ForgotPassword action method, 121–122 CreateCategory.aspx view, 225–229 GetErrorMessage helper method, 120–121 CreateComment action, comment controllers, implementing, 119 217–218 ManageRole action method, 129 CreateDepartment action, department controllers, ManageUsers action method, 126–127 409–411 Registration action method, 119–120 CreateDepartment.aspx view, 387, 424–426 UserProfile action method, 124–126 CreateForum action, forum controllers, 342–343 controllers, news, articles, and blog management CreateForum.aspx view, 332, 356–359 CategoryIndex actions, 201–202 CreateNewsletter action, newsletter controllers, CreateArticle action, 207–209 313–314 CreateCategory action, 213–214 CreateNewsletter.aspx view, 309, 320–323 CreateComment action, 217–218 CreatePoll action, opinion poll controllers, 269–270 designing, 174–175 CreatePoll.aspx view, 262, 284–289 EditArticle action, 209–211 CreatePost action, forum controllers, 346–349 EditCategory action, 214–215 CreatePost.aspx view, 331, 370–372 EditComment action, 218–219 CreateProduct action, product controllers, 414–415 implementing, 199 CreateProduct.aspx view, 387, 429–433 Index action, 199–201 CreateRole action method, membership system ManageArticle action, 205–206 controller action, 129 RateArticle action, 204–205 CreateShipping action, shipping controller actions, RemoveArticle action, 212–213 420–421 RemoveCategory action, 216–217 cross-site scripting attacks, 168 RemoveComment action, 219–220 CSS (Cascading Style Sheets) ViewArticle action, 202–204 creating site design, 52–54 controllers, newsletter creating style sheets, 57–61 CreateNewsletter action, 313–314 designing styles for web site, 37–40 designing, 310 displaying tabular data with, 40–41 EditNewsletter action, 314–315 MVC and, 9 implementing, 311 CSS Templates, 36 Index action, 312 culture ManageNewsletters action, 312–313 cultural information class, 468–469 RemoveNewsletter action, 317 setting current culture, 469–471 SendNewsletter non-action, 315–316 current poll view, opinion polls, 292–293 UpdateStatus action, 313 CurrentPoll query, LINQ queries for opinion polls, controllers, opinion poll 264–265 AddOption action, 273

506

10950bindex.indd 506 5/13/09 4:51:07 PM Design section

default files in project creation and, 24 D IIS versions and, 52 DAL (data access layer), 67–74 DeleteProduct action, e-commerce controllers, 417 designing, 67 DeleteRole action method, membership controllers, layered design and, 64–65 129–130 LINQ Entity Framework, 72 DeleteShipping action, e-commerce LINQ impact on, 69–71 controllers, 421 LINQ-to-SQL, 71–72 DeleteShoppingCartItem action, e-commerce multiple data store support, 67–69 controllers, 402–403 securing, 72–74 DeleteUser action method, membership data, caching, 76 controllers, 127 data access layer. See DAL (data access layer) DepartmentItem.ascx control, 429 data stores departments, e-commerce store choosing, 66–67 CreateDepartment action, 409–411 exploring default SQL Server data store, 98–100 CreateDepartment.aspx view, 424–426 layered design and, 64 designing multiple departments, 376 multiple data store support, 67–69 EditDepartment action, 411–412 provider model design pattern and, 93 ManageDepartment.aspx view, 427–429 database locking, multi-threading and, 306 ManageDepartments action, 409 Database Meta Language (DBML) ViewDepartment action, 398–399 extending LINQ objects to add business functionality ViewDepartment.aspx views, 440–441 to forums, 334 deploying Web sites. See site deployment LINQ-to-SQL and, 179–180 Design section, TheBeerHouse project, 2–3 databases Design section, e-commerce store designing tables for newsletters, 307 configuration module design, 384 importing existing data into, 486–490 controller design, 387–389 databases, deploying database table design, 382–383 attach method for, 480–483 model design, 384–386 scripted solution for, 486–490 online payment options, 377–380 to SQL Server 2008, 479 overview of, 376–377 databases, for e-commerce store PayPal as payment service, 380–382 building, 389–391 transaction preservation, 383–384 table design, 382–383 view design, 386–387 transaction preservation, 383–384 Design section, forums databases, for forums configuration module design, 330 querying, 329–330 controller design, 332 table design, 329 database queries, 329–330 databases, for membership system database table design, 329 configuring, 115–116 model design, 330–331 designing tables for, 109 overview of, 328 databases, for news, articles, and blogs view design, 331–332 designing tables for, 155 Design section, localization querying, 159–161 cultural information class, 468–469 databases, for opinion polls global resources, 465–467 designing tables, 259–260 overview of, 462 querying, 260 page-level resources, 467–468 working with, 262–263 setting current culture, 469–471 DataContext class, transaction management and, 78 Design section, membership system DBML (Database Meta Language) accessing user profiles, 106 extending LINQ objects to add business functionality anonymous user support, 106–107 to forums, 334 ASP.NET Web-based administration tools, 107–108 LINQ-to-SQL and, 179–180 authentication options, 88 declarative coding, 176 authorization roles, 100–102 decoupling tiers, of multi-tier design, 63 controllers designed for, 111–112 Default.asax database table design, 109

507

10950bindex.indd 507 5/13/09 4:51:07 PM Design section (continued)

Design section, membership system (continued) model design, 261 Design section, 109 querying database, 260 exploring default SQL Server data store, 98–100 view design, 261–262 features to implement, 109 Design section, site deployment models designed for, 109–110 database deployed to SQL Server 2008, 479 overview of, 86 MVC Framework applications, 478 password storage mechanisms, 87–88 MVC web application deployment, 479–480 profiling user information, 104–106 overview of, 478 provider model design pattern, 93–96 Design section, site design securing controller actions, 103–104 accessibility of site, 48 security module built into MVC framework, 108 accessing master page from content pages, 44–45 SqlMembershipProvider, 96–97 avoiding use of HTML tables for layout control, 40–41 System.Web.Security.Membership class, 89–93 CSS styles, 37–40 views designed for, 110–111 master page feature, 42–44 Design section, news, articles, and blogs navigation system, 46–47 Article class, 166–168 nesting master pages, 44 article extension method queries, 163–164 overview of, 34–35 article item view user control, 172–173 sharing common behavior among pages, 49–50 Articles table, 157–159 sharing common design between multiple pages, Categories table, 156–157 41–42 Category class, 168 site layout, 35–36 category extension method queries, 164–165 switching master pages at runtime, 46 Comment class, 168–170 technologies for implementing design, 36–37 Comments table, 159 top-level navigation, 47–48 configuration module design, 161 designing sites. See site design controller design, 174–175 developers, graphic designers assisting, 363 database table design, 155 discounts, selling products online and, 376 extending model, 162–163 discussion boards. See forums features to implement, 153–154 distributed authentication system, 88 images included in articles, 172 DIVs, displaying tabular data with, 40–41 model design, 161–162, 165 DOM (Document Object Model), 220–221 producing/consuming Atom feeds, 173–174 dynamic content, 2 queries accessing database, 159–161 security and, 176 view design, 170–171 E writing articles with WYSIWYG editor, 171–172 e-commerce store Design section, newsletters AddShoppingCartItem action, 401–402 background threads, 302–306 CompleteOrder action, 403–408 configuration module design, 307–308 CompleteOrder.aspx view, 451 controller design, 310 configuration module design, 384 creating/sending e‑mails, 298–301 configuration module implementation, 392–393 database table design, 307 controller design, 387–389 jQuery for partial view updates, 306–307 controller implementation, 397 managing long operations on server, 301–302 CreateDepartment action, 409–411 model design, 308–309 CreateDepartment.aspx view, 424–426 overview of, 297 CreateProduct action, 414–415 spam and, 297–298 CreateProduct.aspx view, 429–433 view design, 309 CreateShipping action, 420–421 Design section, opinion polls, 257 database construction, 389–391 configuration module design, 260 database table design, 382–383 controller design, 262 DeleteProduct action, 417 designing database tables for, 259–260 DeleteShipping action, 421 features to implement, 257–258 DeleteShoppingCartItem action, 402–403 handling multiple votes, 258–259 Design section, 376–377

508

10950bindex.indd 508 5/13/09 4:51:08 PM forums

EditDepartment action, 411–412 EditUser action method, membership system EditProduct action, 415–417 controllers, 127–129 extending LINQ objects, 393–395 EditUser.aspx view, membership system views, important features of content-based sites, 3 145–147 Index action, 398 e‑mail. See also newsletters Index.aspx view, 438–439 creating/sending, 298–301 LINQ queries, 395–397 example of newsletter email, 323 ManageDepartment.aspx view, 427–429 managing e‑mail addresses for newsletter ManageDepartments action, 409 subscriptions, 296 ManageOrder.aspx view, 455–456 spam and, 297–298 ManageOrders action, 418 encryption ManageProducts action, 413 password storage mechanisms, 87–88 ManageProducts.aspx view, 433–436 SSL (Secure Sockets Layer), 377–378 ManageShipping action, 420 Entity Framework, LINQ, 72, 308 ManageShipping.aspx view, 436–438 environment resources, saved in web.config ManageStore action, 408–409 file, 78–79 ManageStore.aspx view, 422–424 exception handling model design, 384–386 GetErrorMessage helper method, 120–121 model implementation, 393 using custom error pages, 77–78 online payment options, 377–380 Exist query, LINQ, 198 order management views, 455 expressions, localization, 464 order processing views, 446–451 extension methods OrderDetail action, 418–420 article extension method queries, 163–164 OrderDetail.aspx view, 456–459 category extension method queries, 164–165 overview of, 375 HTML and AJAX extension methods and, 29 PayPal as payment service, 380–382 ExtractValue method, of CompleteOrder Problem section, 375–376 action, 407 product reviews and, 327 Solution section, 389 storefront administration views, 421–422 F storefront views, 438 file structures, project creation and, 22 summary, 459–460 filters, controller, 31–32 transaction preservation, 383–384 TransactionError.aspx view, 452–454 news feed readers, 152 view design, 386–387 site design and browser compatibility, 34 view implementation, 421 Flash, search engine optimization and, 81 ViewDepartment action, 398–399 Flickr, high-quality images with, 172 ViewDepartment.aspx views, 440–441 foreign keys ViewProduct action, 399 for opinion poll database, 259 ViewProduct.aspx views, 441–443 table relationships and, 178 ViewShoppingCart action, 399–400 ForgotPassword action, membership system ViewShoppingCart.aspx views, 443–446 controllers, 121–122 EditArticle action, article controllers, 209–211 ForgotPassword.aspx view, membership system EditCategory action, category controllers, 214–215 views, 136–138 EditComment action, comment controllers, 218–219 forms-based authentication, vs. Windows EditDepartment action, e-commerce controllers, authentication, 88 411–412 forums EditForum action, forum controllers, 343–345 AdminSidebar.ascx control, 350–351 EditNewsletter action, newsletter controllers, ClosePost action, 349–350 314–315 configuration module design, 330 EditOption action, opinion poll controllers, 273–274 configuration module implementation, 333 editor role, articles management, 176 controller design, 332 EditPoll action, opinion poll controllers, 270–271 controller implementation, 336 EditProduct action, e-commerce controllers, CreateForum action, 342–343 415–417

509

10950bindex.indd 509 5/13/09 4:51:08 PM forums (continued)

forums (continued) GetProduct query, LINQ queries, 396 CreateForum.aspx view, 356–359 GetProducts query, LINQ queries, 396–397 CreatePost action, 346–349 GetPublishedArticles query, LINQ queries, 193–194 CreatePost.aspx view, 370–372 GetPublishedArticlesCount query, LINQ queries, 195 database queries, 329–330 GetReplies query, LINQ queries, 336 database table design, 329 GetShippingMethod query, LINQ queries, 395 Design section, 328 GetShippingMethods query, LINQ queries, 395 EditForum action, 343–345 GetVote query, LINQ queries, 335 Index action, 337 global resources Index.aspx view, 360–361 strongly typed, 464 LINQ queries, 334–336 using, 465–467 ManageForums action, 341 Global.asax file, 24 ManageForums.aspx view, 351–352 globalization, 461. See also localization ManagePosts action, 342 Globally Recognized Avatar (Gravatar), 328 ManagePosts.aspx view, 352–356 extending LINQ objects to add business functionality model design, 330–331 to forum, 334 model implementation, 333 Google, nonlinear paging, 189 overview of, 327 Google Analytics, 256 Problem section, 327–328 Google Chrome, 34 RemoveForum action, 345–346 , 152 RemoveForum.aspx view, 359–360 graphic designers assisting RemovePost action, 350 developers working with, 363 Solution section, 332 site design and, 36 summary, 372–374 Gravatar (Globally Recognized Avatar), 328 view design, 331–332 extending LINQ objects to add business functionality view implementation, 350 to forum, 334 ViewForum action, 337–338 ViewForum.aspx view, 361–365 ViewPost action, 338–339 H ViewPost.aspx view, 365–370 hashing, password storage mechanisms, 87–88 Vote action, 340–341 hosting servers, deployment and, 478 forums.js HTML CreatePost.aspx view, 372 avoiding use of HTML tables for layout control, 40–41 ViewPost.aspx view, 369–370 extension methods, 29 FTP, uploading files with, 172 MVC and, 9 sending e‑mail and, 299 G technologies for working with, 36 GetArticle query, LINQ queries, 197 GetArticles query, LINQ queries, 195–196 I GetArticlesCount query, LINQ queries, 196–197 identity, user. See membership system GetCategories query, LINQ queries, 197 IE (), 34 GetCategory query, LINQ queries, 198 IEnumerable class, 165 GetComment query, LINQ queries, 198 IETF (Internet Engineering Task Force), 151 GetCommentsForModeration query, LINQ queries, 198 IIS (Internet Information Services) GetDepartment query, LINQ queries, 396 configuration settings in web.config file, 79 GetErrorMessage helper method, membership Default.aspx and, 52 system controller, 120–121 IIS 6 configured for MVC framework, 479, 492–495 GetForum query, LINQ queries, 335 IIS 7 configured for MVC framework, 480, 495–502 GetForums query, LINQ queries, 336 images GetPoll query, LINQ queries, 265 included in articles, 172 GetPollOption query, LINQ queries, 265 selling products online and, 376 GetPolls query, LINQ queries, 265–266 imperative coding, 176 GetPost query, LINQ queries, 335 Import/Export Wizard, SSMS, 486 GetPosts query, LINQ queries, 335–336 incentives, subscriber, 296

510

10950bindex.indd 510 5/13/09 4:51:08 PM LINQ (Language Integrated Query)

Index action manage-categories.js, 228–229 e-commerce controllers, 398 manage-department.js, 426 forum controllers, 337 manage-forum.js, 354–356, 358 news, articles, and blog controllers, 199–201 ManageNewsletter.aspx view, 319 newsletter controllers, 312 manage-newsletter.js, 319, 322–323 opinion poll controllers, 266–267 ManagePolls.aspx view, 282 Index.aspx view manage-polls.js, 283–284, 287–289 designing e-commerce views, 386 ManagePosts.aspx view, 354 designing forum views, 331 manage-product.js, 431 designing newsletter views, 309 ManageRole.aspx view, 149 designing opinion poll views, 261 manage-role.js, 149 e-commerce views, 438–439 ManageUser.aspx view, 144–145 forum views, 360–361 poll.js, 279–280 news, articles, and blog management views, 246 Register.aspx view, 132–134 newsletter views, 323–324 register.js, 133 opinion poll views, 291–292 ViewForum.aspx view, 365 overview of, 170 ViewPost.aspx view, 368 initial setup, membership system, 113–115 jQuery InStock query, LINQ queries, 397 default files in project creation and, 23 Internet Engineering Task Force (IETF), 151 for partial view updates, 306–307 Internet Explorer (IE), 34 JSON, 78 Internet Information Services. See IIS (Internet Information Services) introduction, to this book K companion website to book, xxv keywords, search engine optimization and, 82 conventions used, xxv kickers, subscriber incentives, 296 forums and peer discussions, xxvi–xxvii intended audience, xxiv overview of, xxi L requirements and resources needed to use book, xxiv language, localization and, 461–462 source code, xxvi language tables, designing for membership structure of book, xxiii–xxiv system, 109 what is covered in book, xxii–xxiii layout IP locking, handling multiple votes in opinion polling, avoiding use of HTML tables for layout control, 40–41 258–259 designing, 35–36 master pages. See master pages lazy load, LINQ using, 168 J legacy systems, provider model design pattern for JavaScript migration of, 94 best practices for presentation layer, 80 linear paging, through collections, 189–191 commerce.js, for departments, 428 LINQ (Language Integrated Query) commerce.js, for products, 435–436 creating LINQ queries for e-commerce store, 395–397 commerce.js, for shipping carts, 446 creating LINQ queries for forums, 334–336 commerce.js, for shipping methods, 437–438 creating LINQ queries for news, articles and blogs, CreateArticles.aspx view, 238–239 192–198 CreateCategory.aspx view, 228 creating LINQ queries for opinion polls, 264–266 CreateForum.aspx view, 358 DataContext class and, 78 CreateNewsletter.aspx view, 322 Entity Framework, 71–72 CreatePoll.aspx view, 286–287 Exist query, 198 CreatePost.aspx view, 371 extending LINQ objects for e-commerce store, 393– default files in project creation and, 23 395 forums.js, 369–370, 372 extending LINQ objects for forums, 334 integration in web sites, 82–83 extending LINQ objects for news, articles, blogs, manage-articles.js, 239–240 187–189

511

10950bindex.indd 511 5/13/09 4:51:08 PM LINQ (Language Integrated Query) (continued)

LINQ (Language Integrated Query) (continued) ManageCategories.aspx view, 224 lazy load pattern used by, 168 ManageForums.aspx view, 352 queries, 334–336 ManageNewsletter.aspx view, 318 SQL compared with, 69–71 ManagePolls.aspx view, 281–282 LINQ-to-SQL ManagePosts.aspx view, 353–354 classes, 181–186 ManageRole.aspx view, 147–148 entity designer, 308 ManageUser.aspx view, 142–144 vs. Entity Framework, 71–72 Register.aspx view, 131–132 schema for multiple tables, 179–181 RemoveArticles.aspx view, 242 transaction management and, 78 RemoveCategory.aspx view, 230–231 in Visual Studio 2008, 71–72 RemoveForum.aspx view, 359–360 localization RemovePoll.aspx view, 290 in ASP.NET 1.x, 463 UserProfile.aspx view, 140–142 in ASP.NET 2.0, 464–465 ViewForum.aspx view, 362 in ASP.NET 3.5 and MVC, 465 ViewPost.aspx view, 366–368 creating localized controller, 476 maintenance plan, site deployment and, 483–486 creating localized view, 475–476 ManageArticle action, news, articles, and blog cultural information class, 468–469 controllers, 205–206 Design section, 462 ManageArticles.aspx view, 171, 233–235 global resources, 465–467 manage-articles.js, 239–240 importance of localized content on web sites, 3 ManageCategories.aspx view, 171, 222–225 overview of, 461 manage-categories.js, 228–229 page-level resources, 467–468 ManageComments.aspx view, 171, 243–246 Problem section, 461–462 ManageDepartment.aspx view, 387, 427–429 resource file creation, 471–475 manage-department.js, 426 setting current culture, 469–471 ManageDepartments action, e-commerce Solution section, 471 controllers, 409 summary, 476 manage-forum.js TinyMCE and, 172 CreateForum.aspx view, 358 lock statement, C#, 304–306 ManagePosts.aspx view, 354–356 logging, exception handling and, 78 ManageForums action, forum controllers, 341 login ManageForums.aspx view, 331, 351–352 Login.aspx view, 134–136 ManageNewsletter.aspx view, 309, 317–319 tools for creating login pages, 89 manage-newsletter.js, 319, 322–323 Login.aspx view, membership system, 134–136 ManageNewsletters action, newsletter controllers, look and feel, site design and, 33 312–313 ManageOrder.aspx view, 387, 455–456 ManageOrders action, e-commerce controllers, 418 M ManagePolls action, opinion poll controllers, Machine.Config file, 95 268–269 mailing lists, 295. See also newsletters ManagePolls.aspx view, 261, 280–284 MainContent section manage-polls.js ChangePassword.aspx view, 138 CreatePoll.aspx view, 287–289 CreateArticles.aspx view, 237–238 ManagePolls.aspx view, 283–284 CreateCategory.aspx view, 226–228 ManagePosts action, forum controllers, 342 CreateForum.aspx view, 357 ManagePosts.aspx view, 331, 352–356 CreateNewsletter.aspx view, 321–322 manage-product.js, 431 CreatePoll.aspx view, 285–286 ManageProducts action, e-commerce controllers, 413 CreatePost.aspx view, 371 ManageProducts.aspx view, 387, 433–436 EditUser.aspx view, 145–147 ManageRole action method, membership system ForgotPassword.aspx view, 137–138 controllers, 129 Index.aspx view, 291–292, 324, 361 ManageRole.aspx view, 147–149 Login.aspx view, 135–136 manage-role.js, 149 ManageArticles.aspx view, 235

512

10950bindex.indd 512 5/13/09 4:51:08 PM models

ManageShipping action, e-commerce ManageRole action method, 129 controllers, 420 ManageRole.aspx view, 147–149 ManageShipping.aspx view, 387, 436–438 ManageUser.aspx view, 142–145 ManageStore action, e-commerce controllers, ManageUsers action method, 126–127 408–409 model design, 109–110 ManageStore.aspx view, 387, 422–424 model implementation, 117–119 ManageUser.aspx view, 142–145 newsletters and, 297 ManageUsers action method, membership system overview of, 85 controllers, 126–127 password storage mechanisms, 87–88 marketing, targeting user profiles, 86 Problem section, 85–86 @Master directive, for master pages, 42 profiling user information, 104–106 master pages provider model design pattern, 93–96 accessing from content pages, 44–45 Register.aspx view, 130–134 creating, 54–57 Registration action method, 119–120 nested, 44 securing controller actions, 103–104 overview of, 33, 42–44 security module built into MVC framework, 108 switching at runtime, 46 Solution section, 112 Membership class SqlMembershipProvider, 96–97 membership providers, 93–96 summary, 149 methods, 89–90 System.Web.Security.Membership class, 89–93 MSDN Library for class details, 91–92 user profile access, 106 membership providers, 93–96 UserProfile action method, 124–126 ASP.NET Web-based administration tools for, 107 UserProfile.aspx view, 139–142 configuring, 95 view design, 110–111 creating new, 94–95 view implementation, 130 overview of, 93–94 MembershipUser class registering, 95–96 methods and properties, 90–92 SqlMembershipProvider, 96–97 MSDN Library for class details, 91–92 membership system menu system, 46–48. See also navigation account box settings, 134 metatags, search engine optimization and, 81–82 anonymous user support, 106–107 methods, controller, 31–32 ASP.NET Web-based administration tools for, 107–108 2007, news feed readers, 152 authentication options, 88 Microsoft SQL Server. See SQL Server authorization roles, 100–102 Microsoft Web Platform Installer, 499–502 ChangePassword action method, 123–124 Microsoft.NET Framework 3.5 SP1 ChangePassword.aspx view, 138–139 ASP.NET MVC prerequisites, 13 controller design, 111–112 Syndication model in, 251 controller implementation, 119 mock-ups, site design and, 35–36 CreateRole action method, 129 models database configuration, 115–116 in Atwood’s example, 9 database table design, 109 author’s definition, 9 DeleteRole action method, 129–130 business layer and domain objects in, 25–26 DeleteUser action method, 127 Reenskaug’s definition of, 8 Design section, 87, 109 models, e-commerce store EditUser action method, 127–129 designing, 384–386 EditUser.aspx view, 145–147 extending LINQ objects, 393–395 exploring default SQL Server data store, 98–100 implementing, 393 features to implement, 109 LINQ queries, 395–397 ForgotPassword action method, 121–122 models, forums ForgotPassword.aspx view, 136–138 designing, 330–331 GetErrorMessage helper method, 120–121 extending LINQ objects, 334 initial setup, 113–115 implementing, 333 Login.aspx view, 134–136 LINQ queries, 334–336

513

10950bindex.indd 513 5/13/09 4:51:08 PM models

models, membership system nested master pages, 44 designing, 109–110 network properties, designing configuration module implementing, 117–119 for newsletters, 308 models, news, articles, and blogs news, articles, and blog management Article class, 166–168 AdminSidebar.ascx control, 222 Category class, 168 Article class, 166–168 Comment class, 168–170 article extension method queries, 163–164 defining the model, 165 article item view user control, 172–173 designing, 161–162 ArticleItem.ascx control, 231–233 extending, 162–163 Articles table, 157–159 models, newsletter Atom feeds, 173–174 designing, 308–309 Atom syndication view, 251–253 implementing, 311 Categories table, 156–157 models, opinion polls Category class, 168 CurrentPoll query, 264–265 category extension method queries, 164–165 designing, 261 CategoryIndex actions, 201–202 GetPoll query, 265 CategoryIndex.aspx view, 246 GetPollOption query, 265 CategoryItem.ascx control, 220–222 GetPolls query, 265–266 Comment class, 168–170 implementing, 264–266 CommentItem.ascx control, 242–243 LINQ queries, 264 Comments table, 159 Model-View-Controller (MVC) pattern. See also MVC configuration module design, 161 framework controller design, 174–175 defined, 9–10 controller implementation, 199 overview of, 7–9 CreateArticle action, 207–209 moderation, of forums, 328 CreateArticles.aspx view, 235–241 MoxieCode Systems, TinyMCE, 171–172 CreateCategory action, 213–214 Mozilla Firefox CreateCategory.aspx view, 225–229 news feed readers, 152 CreateComment action, 217–218 site design and browser compatibility, 34 database table design, 155 multi-threaded programming, 303 Design section, 153 multi-tier design EditArticle action, 209–211 defined, 63 EditCategory action, 214–215 designing layered infrastructure, 64–65 EditComment action, 218–219 MVC (Model-View-Controller) pattern extending LINQ objects, 187–189 defined, 9–10 extending model, 162–163 overview of, 7–9 features to implement, 153–154 MVC framework images included in articles, 172 architectural planning and, 64 implementing configuration module, 176–177 challenges when deploying applications, 478 Index action, 199–201 deploying MVC web site, 491–492 Index.aspx view, 246 IIS 6 configured for, 492–495 LINQ queries, 192–198 IIS 7 configured for, 495–502 LINQ-to-SQL classes, 181–186 MVC web application deployment, 479–480 LINQ-to-SQL schema, 179–181 preparing to deploy MVC web applications, 490–491 ManageArticle action, 205–206 security and, 75 ManageArticles.aspx view, 233–235 ManageCategories.aspx view, 222–225 ManageComments.aspx view, 243–246 N model design, 161–162, 165 names overview of, 151 database table names, 155 page-able collections, creating, 189–191 username, 480–481 Problem section, 151–153 navigation queries accessing database, 159–161 overview of navigation system, 46–47 RateArticle action, 204–205 site maps and breadcrumbs as navigational hints, 33 RemoveArticle action, 212–213 top-level navigation, 47–48 RemoveArticles.aspx view, 241–242

514

10950bindex.indd 514 5/13/09 4:51:08 PM output options

RemoveCategory action, 216–217 OpenID, distributed authentication system, 88 RemoveCategory.aspx view, 229–231 opinion polls RemoveComment action, 219–220 AddOption action, 273 securing the viewing of articles, 191–192 AdminSidebar.ascx control, 280 security and, 176 configuration module design, 260 Solution section, 176 configuration module implementation, 263–264 summary, 253–254 controller design, 262 table relationships, 177–178 controller implementation, 266 view design, 170–171 CreatePoll action, 269–270 view implementation, 220 CreatePoll.aspx view, 284–289 ViewArticle action, 202–204 current poll, 292–293 ViewArticle.aspx view, 246–251 Design section, 257 writing articles with WYSIWYG editor, 171–172 designing database tables for, 259–260 news aggregators, 151 EditOption action, 273–274 newsfeeds, XML index documents, 151 EditPoll action, 270–271 newsletters features to implement, 257–258 background threads, 302–306 handling multiple votes, 258–259 configuration module design, 307–308 Index action, 266–267 configuring web.config, 310–311 Index.aspx view, 291–292 controller design, 310 ManagePolls action, 268–269 controller implementation, 311 ManagePolls.aspx view, 280–284 CreateNewsletter action, 313–314 model design, 261 CreateNewsletter.aspx view, 320–323 model implementation, 264–266 creating/sending e‑mails, 298–301 overview of, 255 database table design, 307 PollItem.ascx control, 278–280 Design section, 297 PollResultItem.ascx control, 276–278 EditNewsletter action, 314–315 Problem section, 255–257 Index action, 312 querying database, 260 Index.aspx view, 323–324 RemoveOption action, 274 jQuery for partial view updates, 306–307 RemovePoll action, 271–272 ManageNewsletter.aspx view, 317–319 RemovePoll.aspx view, 289–290 ManageNewsletters action, 312–313 SetArchived action, 275 managing long operations on server, 301–302 SetCurrent action, 274–275 model design, 308–309 Solution section, 262 model implementation, 311 summary, 293 NewsletterStatus.ascx control, 319–320 view design, 261–262 overview of, 295 view implementation, 276 Problem section, 295–296 Vote action, 267–268 RemoveNewsletter action, 317 working with database, 262–263 SendNewsletter non-action, 315–316 OrderDetail action, e-commerce controllers, Solution section, 310 418–420 spam and, 297–298 OrderDetail.aspx view, 387, 456–459 summary, 325 orders, e-commerce UpdateStatus action, 313 CompleteOrder action, 403–408 view design, 309 CompleteOrder.aspx view, 386, 451 view implementation, 317 ManageOrder.aspx view, 387, 455–456 NewsletterStatus.ascx control, 319–320 ManageOrders action, 418 nonlinear paging, through collection, 189–191 order management views, 455 n-tier design. See multi-tier design order processing views, 446–451 OrderDetail action, 418–420 OrderDetail.aspx view, 387, 456–459 O TransactionError.aspx view, 452–454 online payment output options, controller classes and, 78 options, 377–380 PayPal as payment service, 380–382

515

10950bindex.indd 515 5/13/09 4:51:08 PM page-level resources

presentation layer (UI). See also UI (user interface) P best practices for, 80 page-level resources layered design and, 65 new in ASP.NET 2.0, 464 primary keys using, 467–468 for opinion poll database, 259 paging through collections, linear vs. nonlinear, table relationships and, 178 189–191 Problem section Paint.NET, 35 architectural planning, 63–64 partial classes TheBeerHouse project, 1–2 extending objects and, 186 e-commerce store, 375–376 HTML models in ASP.NET, 36 forums, 327–328 passwords localization, 461–462 attach method for database deployment and, 480– membership system, 85–86 481 news, articles, and blogs, 151–153 ChangePassword action method, 123–124 newsletters, 295–296 ChangePassword.aspx view, 138–139 opinion polls, 255–257 ForgotPassword action method, 121–122 site deployment, 477–478 ForgotPassword.aspx view, 136–138 site design, 33–34 not storing in clear text, 97 Problem-Design-Solution approach storage mechanisms, 87–88 Design sections. See Design section payment overview of, 1 online payment options, 377–380 Problem sections. See Problem section PayPal as payment service, 380–382 Solution sections. See Solution section payment gateways, 377–380 processes, best practices for presentation layer, 80 PayPal, 380–382 product reviews, 327 performance products, e-commerce store best practices for speeding up websites, 57 CreateProduct action, 414–415 caching data and, 76 CreateProduct.aspx view, 429–433 permissions, managing user accounts, 86 DeleteProduct action, 417 personalization EditProduct action, 415–417 important features of content-based sites, 2 ManageProducts action, 413 newsletters and, 296 ManageProducts.aspx view, 433–436 plain-text, sending e‑mail and, 299 ViewProduct action, 399 planning architecture. See architecture, planning ViewProduct.aspx views, 441–443 policy statements, forums and, 329 Profile module, ASP.NET, 104 poll box, user control for, 257 ProfileInformation class PollItem.ascx control, 278–280 designing models for managing user membership, 110 poll.js, 279–280 implementing models for managing user membership, PollResultItem.ascx control, 276–278 117 polls. See opinion polls profiles. See user profiles pop-ups, best practices for presentation layer, 80 projects, ASP.NET MVC, 25–26 Post class, 334 provider model design pattern posts, to forums designing membership system and, 93–96 ClosePost action, 349–350 migration of legacy systems and, 94 CreatePost action, 346–349 multiple data store support, 67–69 CreatePost.aspx view, 370–372 designing for, 328 ManagePosts action, 342 Q ManagePosts.aspx view, 352–356 queries RemovePost action, 350 article extension method queries, 163–164 ViewPost action, 338–339 category extension method queries, 164–165 ViewPost.aspx view, 365–370 creating LINQ queries for e-commerce store, 395–397 prerequisites, ASP.NET MVC creating LINQ queries for forums, 334–336 installing, 13–19 list of, 13

516

10950bindex.indd 516 5/13/09 4:51:08 PM SEO (search engine optimization)

creating LINQ queries for news, articles and blogs, roles, authorization 192–198 CreateRole action method, 129 that access forum database, 329–330 DeleteRole action method, 129–130 that access opinion poll database, 260 ManageRole action method, 129 that access the news, articles, and blog database, ManageRole.aspx view, 147–149 159–161 overview of, 100–102 RSS (Really Simple Syndication) content syndication with, 151–152 R making content accessible as RSS feed, 154 RateArticle action, news, articles, and blog RSS Bandit, 152 controllers, 204–205 RDBMSs (Relational Database Management Systems), 66–67 S Really Simple Syndication. See RSS (Really Simple Safari browser, Apple, 34 Syndication) Sandbox, PayPal, 381 Reenskaug, Trygve, 7 screen readers, accessibility and, 40–41 Register.aspx view screen-scraping, for data retrieval, 151 MainContent section, 131–132 ScriptContent section membership system views, 130–134 CreateArticles.aspx view, 238–239 ScriptContent section, 132–134 CreateCategory.aspx view, 228 register.js, 133 CreateForum.aspx view, 358 registration CreateNewsletter.aspx view, 322 newsletter members, 297 CreatePoll.aspx view, 286–287 Register.aspx view, 130–134 CreatePost.aspx view, 371 Registration action method, 119–120 ManageNewsletter.aspx view, 319 Registration action method, membership system ManagePolls.aspx view, 282 controller, 119–120 ManagePosts.aspx view, 354 Relational Database Management Systems ManageRole.aspx view, 149 (RDBMSs), 66–67 ManageUser.aspx view, 144–145 relationships, between database tables, 177–178 Register.aspx view, 132–134 RemoveArticle action, news, articles, and blog ViewForum.aspx view, 365 controllers, 212–213 ViewPost.aspx view, 368 RemoveArticles.aspx view, 171, 241–242 scripted solution, for database deployment, 479, RemoveCategory action, news, articles, and blog 486–490 controllers, 216–217 script-injection attacks, 168 RemoveCategory.aspx view, 171, 229–231 search engine optimization (SEO) RemoveComment action, news, articles, and blog making site content accessible to search controllers, 219–220 engines, 152 RemoveForum action, forum controllers, 345–346 overview of, 81–82 RemoveForum.aspx view, 332, 359–360 Secure Sockets Layer (SSL), 377–378 RemoveNewsletter action, newsletter security controllers, 317 ASP.NET Web-based administration tools for, 107 RemoveOption action, opinion poll controllers, 274 attach method for database deployment and, 480 RemovePoll action, opinion poll controllers, 271–272 DAL (data access layer) and, 72–74 RemovePoll.aspx view, 262, 289–290 issues in ASP.NET, 75 RemovePost action, forum controllers, 350 news, articles, and blog management and, 176 resource files, creating, 471–475 security module, built into MVC framework, 108 resources selectors, controller, 31–32 global, 465–467 SendNewsletter non-action, 315–316 page-level, 467–468 SEO (search engine optimization) results, controller, 31–32 making site content accessible to search revenue options, for Web sites, 375 engines, 152 reviewing products, e-commerce and, 327 overview of, 81–82

517

10950bindex.indd 517 5/13/09 4:51:08 PM Server Explorer

Server Explorer, Visual Studio 2008, 262–263 Design section, 34–35 servers master pages and, 42–44 deployment and, 477–478 navigation system, 46–47 managing long operations on, 301–302 nesting master pages, 44 SetArchived action, opinion poll controllers, 275 overview of, 33 SetCurrent action, opinion poll controllers, 274–275 Problem section, 33–34 sharing sharing common design between multiple common behavior among pages, 49–50 pages, 41–42 common design between multiple pages, 41–42 site layout, 35–36 multi-threading and shared resources, 304 Solution section, 50–52 shipping methods summary, 61 CreateShipping action, 420–421 switching master pages at runtime, 46 DeleteShipping action, 421 technologies for implementing design, 36–37 ManageShipping action, 420 top-level navigation, 47–48 ManageShipping.aspx view, 436–438 site statistics, 256 selling products online and, 377 SMTP (Simple Mail Transfer Protocol) shopping carts designing configuration module for newsletters, 307 AddShoppingCartItem action, 401–402 mail protocol, 298–301 DeleteShoppingCartItem action, 402–403 Solution section, TheBeerHouse project, 4–5 selling products online and, 377 Solution section, e-commerce store, 389 ViewShoppingCart action, 399–400 AddShoppingCartItem action, 401–402 ViewShoppingCart.aspx views, 443–446 CompleteOrder action, 403–408 ShoppingCart class, 394–395 CompleteOrder.aspx view, 451 ShoppingCartItem class, 393 configuration module implementation, 392–393 SidebarContent section controller implementation, 397 ManageCategories.aspx view, 225 CreateDepartment action, 409–411 ManageForums.aspx view, 352 CreateDepartment.aspx view, 424–426 ManagePolls.aspx view, 282 CreateProduct action, 414–415 Simple Mail Transfer Protocol (SMTP) CreateProduct.aspx view, 429–433 designing configuration module for newsletters, 307 CreateShipping action, 420–421 mail protocol, 298–301 database construction, 389–391 site deployment DeleteProduct action, 417 attach method for database deployment, 480–483 DeleteShipping action, 421 backup and maintenance plan, 483–486 DeleteShoppingCartItem action, 402–403 database deployed to SQL Server 2008, 479 EditDepartment action, 411–412 deploying MVC web site, 491–492 EditProduct action, 415–417 Design section, 478 extending LINQ objects, 393–395 IIS 6 configured for MVC framework, 492–495 Index action, 398 IIS 7 configured for MVC framework, 495–502 Index.aspx view, 438–439 MVC framework applications and, 478 LINQ queries, 395–397 MVC web application deployment, 479–480 ManageDepartment.aspx view, 427–429 overview of, 477 ManageDepartments action, 409 preparing to deploy MVC web applications, 490–491 ManageOrder.aspx view, 455–456 Problem section, 477–478 ManageOrders action, 418 scripted solution for database deployment, 486–490 ManageProducts action, 413 Solution section, 480 ManageProducts.aspx view, 433–436 summary, 502 ManageShipping action, 420 site design ManageShipping.aspx view, 436–438 accessibility and, 48 ManageStore action, 408–409 avoiding using HTML tables for layout control, 40–41 ManageStore.aspx view, 422–424 content pages, accessing master page from, 44–45 model implementation, 393 creating, 52–54 order management views, 455 creating master page, 54–57 order processing views, 446–451 creating style sheets, 57–61 OrderDetail action, 418–420 CSS styles and, 37–40 OrderDetail.aspx view, 456–459

518

10950bindex.indd 518 5/13/09 4:51:09 PM Solution section

storefront administration views, 421–422 ForgotPassword action method, 121–122 storefront views, 438 ForgotPassword.aspx view, 136–138 TransactionError.aspx view, 452–454 GetErrorMessage helper method, 120–121 view implementation, 421 initial setup, 113–115 ViewDepartment action, 398–399 Login.aspx view, 134–136 ViewDepartment.aspx views, 440–441 ManageRole action method, 129 ViewProduct action, 399 ManageRole.aspx view, 147–149 ViewProduct.aspx views, 441–443 ManageUser.aspx view, 142–145 ViewShoppingCart action, 399–400 ManageUsers action method, 126–127 ViewShoppingCart.aspx views, 443–446 model implementation, 117–119 Solution section, forums overview of, 112 AdminSidebar.ascx control, 350–351 Register.aspx view, 130–134 ClosePost action, 349–350 Registration action method, 119–120 configuration module implementation, 333 UserProfile action method, 124–126 controller implementation, 336 UserProfile.aspx view, 139–142 CreateForum action, 342–343 view implementation, 130 CreateForum.aspx view, 356–359 Solution section, news, articles, and blogs CreatePost action, 346–349 AdminSidebar.ascx control, 222 CreatePost.aspx view, 370–372 ArticleItem.ascx control, 231–233 EditForum action, 343–345 Atom syndication view, 251–253 extending LINQ objects, 334 CategoryIndex actions, 201–202 Index action, 337 CategoryIndex.aspx view, 246 Index.aspx view, 360–361 CategoryItem.ascx control, 220–222 LINQ queries, 334–336 CommentItem.ascx control, 242–243 ManageForums action, 341 controller implementation, 199 ManageForums.aspx view, 351–352 CreateArticle action, 207–209 ManagePosts action, 342 CreateArticles.aspx view, 235–241 ManagePosts.aspx view, 352–356 CreateCategory action, 213–214 model implementation, 333 CreateCategory.aspx view, 225–229 overview of, 332 CreateComment action, 217–218 RemoveForum action, 345–346 EditArticle action, 209–211 RemoveForum.aspx view, 359–360 EditCategory action, 214–215 RemovePost action, 350 EditComment action, 218–219 view implementation, 350 extending LINQ objects, 187–189 ViewForum action, 337–338 implementing configuration module, 176–177 ViewForum.aspx view, 361–365 Index action for displaying published articles, ViewPost action, 338–339 199–201 ViewPost.aspx view, 365–370 Index.aspx view, 246 Vote action, 340–341 LINQ queries, 192–198 Solution section, localization LINQ-to-SQL classes, 181–186 creating localized controller, 475–476 LINQ-to-SQL schema, 179–181 creating localized view, 474–475 ManageArticle action, 205–206 overview of, 471 ManageArticles.aspx view, 233–235 resource file creation, 471–474 ManageCategories.aspx view, 222–225 Solution section, membership system ManageComments.aspx view, 243–246 account box settings, 134 overview of, 176 ChangePassword action method, 123–124 page-able collections, creating, 189–191 ChangePassword.aspx view, 138–139 RateArticle action, 204–205 controller implementation, 119 RemoveArticle action, 212–213 CreateRole action method, 129 RemoveArticles.aspx view, 241–242 database configuration, 115–116 RemoveCategory action, 216–217 DeleteRole action method, 129–130 RemoveCategory.aspx view, 229–231 DeleteUser action method, 127 RemoveComment action, 219–220 EditUser action method, 127–129 securing the viewing of articles, 191–192 EditUser.aspx view, 145–147 table relationships, 177–178

519

10950bindex.indd 519 5/13/09 4:51:09 PM Solution section (continued)

Solution section, news, articles, and blogs (continued) Solution section, site design process, 50–52 view implementation, 220 creating master page, 54–57 ViewArticle action, 202–204 creating site design, 52–54 ViewArticle.aspx view, 246–251 creating style sheet, 57–61 Solution section, newsletters sorting comments, 169–170 configuring web.config, 310–311 spam, newsletters and, 297–298 controller implementation, 311 SQL (Structured Query Language), 69–71 CreateNewsletter action, 313–314 SQL injection attaches, 72–74 CreateNewsletter.aspx view, 320–323 SQL Server EditNewsletter action, 314–315 ASP.NET MVC prerequisites, 13, 15–16 Index action, 312 choosing as RDBMS, 66–67 Index.aspx view, 323–324 deploying database to SQL Server 2008, 479 ManageNewsletter.aspx view, 317–319 exploring default SQL Server data store, 98–100 ManageNewsletters action, 312–313 SQL Server Management Studio. See SSMS (SQL model implementation, 311 Server Management Studio) NewsletterStatus.ascx control, 319–320 SqlMembershipProvider, 96–97 overview of, 310 SSL (Secure Sockets Layer), 377–378 RemoveNewsletter action, 317 SSMS (SQL Server Management Studio) SendNewsletter non-action, 315–316 ASP.NET MVC prerequisites, 13 UpdateStatus action, 313 attach database using, 480 view implementation, 317 importing existing data into database, 486–490 Solution section, opinion polls, 262 setting up backup plan in, 483 AddOption action, 273 Stat Counter, 256 AdminSidebar.ascx control, 280 statistics services, Web sites, 256 configuration module implementation, 263–264 stock availability, product sales and, 376 controller implementation, 266 storage mechanisms, passwords, 87–88 CreatePoll action, 269–270 store departments. See departments, CreatePoll.aspx view, 284–289 e-commerce store current poll, 292–293 storefront administration views EditOption action, 273–274 CreateDepartment.aspx view, 424–426 EditPoll action, 270–271 CreateProduct.aspx view, 429–433 Index action, 266–267 ManageDepartment.aspx view, 427–429 Index.aspx view, 291–292 ManageProducts.aspx view, 433–436 ManagePolls action, 268–269 ManageShipping.aspx view, 436–438 ManagePolls.aspx view, 280–284 ManageStore.aspx view, 422–424 model implementation, 264–266 overview of, 421–422 PollItem.ascx control, 278–280 storefront views PollResultItem.ascx control, 276–278 Index.aspx view, 438–439 RemoveOption action, 274 overview of, 438 RemovePoll action, 271–272 ViewDepartment.aspx views, 440–441 RemovePoll.aspx view, 289–290 ViewProduct.aspx views, 441–443 SetArchived action, 275 ViewShoppingCart.aspx views, 443–446 SetCurrent action, 274–275 Structured Query Language (SQL), 69–71 view implementation, 276 subscriptions Vote action, 267–268 as revenue option, 375 working with database, 262–263 storing subscription data, 297 Solution section, site deployment subscriber incentives, 296 attach method for database deployment, 480–483 symmetric encryption, passwords and, 87 backup and maintenance plan, 483–486 syndication, Atom, 173–174, 251–253 IIS 6 configured for MVC framework, 492–495 System.Collections.Generic.IEnumerable IIS 7 configured for MVC framework, 495–502 class, 165 MVC application deployment, 491–492 System.Globalization.CultureInfo, 463 overview of, 480 System.Net.Mail namespace, 298 preparing to deploy MVC web applications, 490–491 System.Web.Routing class, 103 scripted solution for database deployment, 486–490 System.Web.Security.Membership class

520

10950bindex.indd 520 5/13/09 4:51:09 PM ViewProduct.aspx view

methods, 89–90 presentation layer (UI) and, 79 MSDN Library for class details, 91–92 search engine optimization, 81–82 System.Web.Security.MembershipUser class views and, 80–81 methods and properties, 90–92 unit testing MSDN Library for class details, 91–92 BLL and, 74 System.Web.Security.Roles class options available during project creation, 21 methods, 101 updates, partial view updates for newsletters, MSDN Library for class details, 102 306–307 UpdateStatus action, newsletter controllers, 313 URL routes, controller and, 30–31 T user interface. See UI (user interface) tables, database user profiles Articles table, 157–159 accessing, 106 Categories table, 156–157 anonymous user support, 106–107 Comments table, 159 defined, 86 designing for e-commerce store, 382–383 DeleteUser action method, 127 designing for forums, 329 EditUser action method, 127–129 designing for membership system, 109 EditUser.aspx view, 145–147 designing for news, articles, and blogs, 155 ManageUser.aspx view, 142–145 designing for newsletters, 307 ManageUsers action method, 126–127 designing for opinion polls, 259–260 profiling user information, 104–106 naming, 155 UserProfile action method, 124–126 relationships between, 177–178 UserProfile.aspx view, 139–142 tables, HTML UserInformation class avoiding use of HTML tables for layout control, 40–41 designing models for managing user membership, 110 best practices for presentation layer, 80 implementing models for managing user membership, technologies, for implementing site design, 36–37 117 TempData property, views, 28–29 username, database deployment an, 480–481 Template Monster, 36 UserProfile action method, membership system templates, for site design, 36 controllers, 124–126 testing frameworks, 21 UserProfile.aspx view, 139–142 text editors, writing articles with WYSIWYG editor, users. See also membership system 171–172 account box settings, 134 threads communication features of content-based sites, 3 background threads, 302–306 managing user accounts, 86 forums and, 328 user-to-user communication TinyMCE, 171–172, 328 importance of, 327 top-level navigation, 47–48 uses of opinion polls, 255 transaction management, 78 preservation, 383–384 V TransactionDataRequest method, CompleteOrder ViewArticle action, news, articles, and blog action, 404–406 controllers, 202–204 TransactionError.aspx view ViewArticle.aspx view, 170, 246–251 e-commerce views, 387 ViewData property, views, 28 order processing views, 452–454 ViewDepartment action, e-commerce controllers, transparent collection enumerator, 191–192 398–399 ViewDepartment.aspx view, 386, 440–441 ViewForum action, forum controllers, 337–338 U ViewForum.aspx view, 331, 361–365 UI (user interface) ViewMasterPage, 27–28 best practices for presentation layer, 80 ViewPage, 27–28 importance of appearance, 2 ViewPost action, forum controllers, 338–339 JavaScript integration, 82–83 ViewPost.aspx view, 331, 365–370 layered design and, 65 ViewProduct action, e-commerce controllers, 399 ViewProduct.aspx view, 386, 441–443

521

10950bindex.indd 521 5/13/09 4:51:09 PM views

views Login.aspx view, 134–136 in Atwood’s example, 9 ManageRole.aspx view, 147–149 author’s definition, 9 ManageUser.aspx view, 142–145 creating localized, 474–475 Register.aspx view, 130–134 default view during project creation, 22 UserProfile.aspx view, 139–142 HTML and AJAX extension methods and, 29 views, news, articles, and blogs jQuery for partial view updates, 306–307 AdminSidebar.ascx control, 222 overview of, 26 ArticleItem.ascx control, 231–233 Reenskaug’s definition of, 8 Atom syndication view, 251–253 TempData property, 28–29 CategoryIndex.aspx view, 246 user interface, 80–81 CategoryItem.ascx control, 220–222 view engines, 26–27 CommentItem.ascx control, 242–243 ViewData property, 28 CreateArticles.aspx view, 235–241 ViewMasterPage, ViewPage, and ViewUserControl, CreateCategory.aspx view, 225–229 27–28 designing, 170–171 views, e-commerce store implementing, 220 CompleteOrder.aspx view, 451 Index.aspx view, 246 CreateDepartment.aspx view, 424–426 ManageArticles.aspx view, 233–235 CreateProduct.aspx view, 429–433 ManageCategories.aspx view, 222–225 designing, 386–387 ManageComments.aspx view, 243–246 implementing, 421 RemoveArticles.aspx view, 241–242 Index.aspx view, 438–439 RemoveCategory.aspx view, 229–231 ManageDepartment.aspx view, 427–429 ViewArticle.aspx view, 246–251 ManageOrder.aspx view, 455–456 views, newsletters ManageProducts.aspx view, 433–436 CreateNewsletter.aspx view, 320–323 ManageShipping.aspx view, 436–438 designing, 309 ManageStore.aspx view, 422–424 implementing, 317 order management views, 455 Index.aspx view, 323–324 order processing views, 446–451 ManageNewsletter.aspx view, 317–319 OrderDetail.aspx view, 456–459 NewsletterStatus.ascx control, 319–320 storefront administration views, 421–422 views, opinion polls storefront views, 438 AdminSidebar.ascx control, 280 TransactionError.aspx view, 452–454 CreatePoll.aspx view, 284–289 ViewDepartment.aspx views, 440–441 current poll, 292–293 ViewProduct.aspx views, 441–443 designing, 261–262 ViewShoppingCart.aspx views, 443–446 implementing, 276 views, forums Index.aspx view, 291–292 AdminSidebar.ascx control, 350–351 ManagePolls.aspx view, 280–284 CreateForum.aspx view, 356–359 PollItem.ascx control, 278–280 CreatePost.aspx view, 370–372 PollResultItem.ascx control, 276–278 designing, 331–332 RemovePoll.aspx view, 289–290 implementing, 350 ViewShoppingCart action, e-commerce controllers, Index.aspx view, 360–361 399–400 ManageForums.aspx view, 351–352 ViewShoppingCart.aspx view, 386, 443–446 ManagePosts.aspx view, 352–356 ViewUserControl, 27–28 RemoveForum.aspx view, 359–360 Virtual Terminals, PayPal and, 380 ViewForum.aspx view, 361–365 visual site design. See site design ViewPost.aspx view, 365–370 Visual Studio 2008 views, membership system LINQ-to-SQL designer in, 71–72 account box settings, 134 localization support in, 464 ChangePassword.aspx view, 138–139 opening first ASP.NET MVC project, 19–25 designing, 110–111 Server Explorer, 262–263 EditUser.aspx view, 145–147 tools for creating login and administration pages, 89 ForgotPassword.aspx view, 136–138 Visual Web Developer 2008 Express, 13–15 implementing, 130 Vote action

522

10950bindex.indd 522 5/13/09 4:51:09 PM XML

forum controllers, 340–341 list of features in content-based sites, 2–3 opinion poll controllers, 267–268 revenue options, 375 votes, handling multiple votes in opinion polling, statistics services, 256 258–259 uses of opinion polls on, 255 web.config file configuring, 310–311 W configuring membership providers, 95 W3C environment resources saved in, 78–79 RSS and, 151 modifying when deploying MVC web applications, 480 XHTML and, 48 WebFormViewEngine, 26–27 WCAG (Web Content Accessibility Guidelines), 48 WebKit Project, 34 Web browsers Website Payments Standard option, PayPal, 381 best practices for presentation layer, 80 Windows authentication, 88 search engine optimization and, 81 Windows Server 2008, as hosting server, 478 site design and browser compatibility, 34 WYSIWYG editors, 171–172 Web Content Accessibility Guidelines (WCAG), 48 Web Forms. See ASP.NET Web Forms Web sites X best practices for speeding up, 57 XHTML, 48 companion site for this book, xxv XML deploying. See site deployment data store options, 66 designing. See site design newsfeeds, 151

523

10950bindex.indd 523 5/13/09 4:51:09 PM