pro asp.net 4 cms

316 390 0
pro asp.net 4 cms

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

7.5 x 9.25 spine = 0.71875" 320 page count THE EXPERT’S VOICE ® IN .NET Pro ASP.NET 4 CMS Advanced Techniques for C# Developers Using the .NET 4 Framework Alan Harris Learn the latest features of .NET 4 to build powerful ASP.NET 4 web applications Pro this print for content only—size & color not accurate US $42.99 www.apress.com SOURCE CODE ONLINE www.it-ebooks.info www.it-ebooks.info i Pro ASP.NET 4 CMS Advanced Techniques for C# Developers Using the .NET 4 Framework ■ ■ ■ Alan Harris www.it-ebooks.info ii Pro ASP.NET 4 CMS: Advanced Techniques for C# Developers Using the .NET 4 Framework Copyright © 2010 by Alan Harris All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2712-0 ISBN-13 (electronic): 978-1-4302-2713-7 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editor: Ewan Buckingham, Matthew Moodie Technical Reviewer: Jeff Sanders Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Anne Collett Copy Editor: Kim Wimpsett Compositor: MacPS, LLC Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders- ny@springer-sbm.com, or visit www.springeronline.com. For information on translations, please e-mail rights@apress.com, or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. www.it-ebooks.info iii “What you leave behind is not what is engraved in stone monuments, but what is woven into the lives of others.” —Pericles www.it-ebooks.info iv Contents at a Glance ■Contents at a Glance iv ■Contents v ■About the Author xii ■About the Technical Reviewer xiii ■Acknowledgments xiv ■Introduction xv ■Chapter 1: Visual Studio 2010 and .NET 4 1 ■Chapter 2: CMS Architecture and Development 29 ■Chapter 3: Parallelization 47 ■Chapter 4: Managed Extensibility Framework and the Dynamic Language Runtime 103 ■Chapter 5: jQuery and Ajax in the Presentation Tier 135 ■Chapter 6: Distributed Caching via Memcached 165 ■Chapter 7: Scripting via IronPython 197 ■Chapter 8: Performance Tuning, Configuration, and Debugging 229 ■Chapter 9: Search Engine Optimization and Accessibility 257 ■Index 285 www.it-ebooks.info v Contents ■Contents at a Glance iv ■Contents v ■About the Author xii ■About the Technical Reviewer xiii ■Acknowledgments xiv ■Introduction xv ■Chapter 1: Visual Studio 2010 and .NET 4 1 Who This Book Is For 1 Who This Book Is Not For (or “Buy Me Now, Read Me Later”) 2 What’s New in .NET 4 2 C# Optional and Named Parameters 3 C#’s dynamic Keyword 5 Dynamic and Functional Language Support 10 Parallel Processing 10 Managed Extensibility Framework (MEF) 13 Distributed Caching with Velocity 13 ASP.NET MVC 16 A Tour of Visual Studio 2010 18 Windows Presentation Foundation 18 Historical Debugging 19 Improved JavaScript IntelliSense 21 jQuery Support 22 www.it-ebooks.info ■ CONTENTS vi Building a CMS 24 CMS Functional Requirements 24 Creating the Application Framework 25 Summary 28 ■Chapter 2: CMS Architecture and Development 29 Motivations for Building a CMS 29 Motivations for Using .NET 30 Application Architecture 30 The CMS Application Tiers 32 CommonLibrary: The Data Transfer Objects 33 GlobalModule: The HttpModule 35 Components of a CMS Page 37 Buckets 37 Embeddable Objects 39 Embeddable Permissions 41 Handling CMS Content 43 The Content Table 43 The ContentVersion Table 44 Assembling Content on Demand 44 How Embeddable Objects Handle Versions 46 Summary 46 ■Chapter 3: Parallelization 47 What Is Parallelization? 47 Good Parallelization Candidates 47 Differences from Multithreading 48 Parallel Pitfalls 48 Deadlocks 48 Race Conditions 51 Thread Starvation 54 www.it-ebooks.info ■ CONTENTS vii Amdahl’s Law 55 .NET 4 Parallelization Concepts 56 Task vs. Data Parallelism 56 Task Parallel Library 56 Task.Wait() 57 Parallel.For() and Parallel.ForEach() 59 Parallel LINQ (aka PLINQ) 59 .AsParallel() 60 CMS Parallelization Opportunities 61 Creating a Data Mining Embeddable 62 Expanding the Data Mining Tasks 66 Tagging 70 Tagging on the Client 73 Fleshing Out the Tagging Embeddable 75 What’s in a Name? 76 Handling Tag Input 79 Tag Processing in the Business Tier 82 POST Problems 87 Finalizing Tag Storage 89 Inserting Tags 92 Content Tags 96 Summary 102 ■Chapter 4: Managed Extensibility Framework and the Dynamic Language Runtime 103 Managed Extensibility Framework 103 The Manual Way 103 The MEF Way 105 Working from Usage to Implementation 106 Exposing Libraries via MEF 106 A Simple Plug-in Contract 107 www.it-ebooks.info ■ CONTENTS viii Implementing the Plug-In 107 Using the Plug-In 108 Catalogs and Containers 112 Supporting Multiple Parts 113 Dynamic Language Runtime 117 The dynamic Keyword 118 Benefits of the dynamic Keyword 119 CMS Plug-Ins 120 IEmbeddable 121 Server Controls as Embeddables 122 Displaying Embeddables 124 PageAssembler 125 Additional Methodology Benefits 128 Missing DLLs 128 Exceptions in Embeddables 129 A More Complex Emeddable 130 Breadcrumbs 130 Navigating the CMS Tree 131 Summary 133 ■Chapter 5: jQuery and Ajax in the Presentation Tier 135 An Introduction to jQuery 135 The $() Factory 136 Implicit Iteration 138 Ajax via jQuery 139 Caching and Ajax 140 Avoiding Caching on GET Requests 141 Lightweight Content Delivery with Ajax and HTTP Handlers 142 Handling Asynchronous Errors 147 Handling DOM Modifications 150 Improving the CMS Admin with jQuery 154 www.it-ebooks.info [...]... Release Mode for Production 239 Removing the Server, X-Powered-By, and X-AspNet-Version Headers . 241 Debugging Concepts 244 White-Box vs Black-Box Debuggers 244 User Mode vs Kernel Mode . 245 Historical Debugging via IntelliTrace 246 Collaborative Debugging 250 Importing and Exporting Breakpoints 250 DataTip Pinning... aware of it when the method is used If we call this method providing a CMSFile object, the output is really quite interesting (see Listing 1– 8 and Figure 1 4) Listing 1–8 Calling Our Method with a Dynamic Object static void Main(string[] args) { DisplayFileInformation(new CMSFile{Filename="testfile .cms" , Size=100, Author="Alan Harris"}); } Figure 1 4 The results of a method accepting a dynamic type I Note... myValue = CMSData.SomeDataCall(); // …and add it to the cache for retrieval next time with a 40 minute expiration CMSCache.Add("myKey", myValue, 40 ); } return myValue; 15 www.it-ebooks.info CHAPTER 1 I VISUAL STUDIO 2010 AND NET 4 I Tip With situations such as distributed caching, it’s a good idea to hide the implementation details of the cache behind a custom abstraction (in this case, CMSCache) If... context of a CMS It has proven to be a very interesting ride, indeed A tremendous benefit to the creation of both the system and the book was the early preview and beta of Visual Studio 2010 and NET 4. 0 Case in point: as you’ll see, the new Managed Extensibility Framework makes up a significant part of the business logic in the CMS (and VS2010, which uses MEF for its add-on capabilities) Could the CMS have... for it With NET 4, C# now supports optional and named parameters, providing a cleaner method for completing the same task (see Listing 1–2) Listing 1–2 Handling the Connections in One Method with Optional Parameters /// /// Returns a SQL connection object using the default "CMS" connection if none is provided /// public SqlConnection GetConnection(string conStr= "CMS" ) { return new... 233 Running a WCAT Test Against the CMS .235 Interpreting Performance Results 236 Improving CMS Performance with Caching 237 HTTP.sys and the OutputCache 237 x www.it-ebooks.info I CONTENTS Benchmarking CMS Performance 238 Configuration Considerations 239 Enable Release Mode for Production 239 Removing the Server,... defined in minutes) Finally, the value is returned, and program execution continues 14 www.it-ebooks.info CHAPTER 1 I VISUAL STUDIO 2010 AND NET 4 Figure 1–5 The typical architecture of a system with distributed caching Listing 1– 14 A Pattern for Working with a Distributed Cache // attempt to retrieve the value for "myKey" in the cache string myValue = CMSCache.Exists("myKey"); if (String.IsNullOrEmpty(myValue))... resource-prohibitive I set off on a skunkworks project to create the CMS while the remaining developers kept the existing one chugging along It’s a truly difficult decision to throw away code A lot of developers worked on the previous CMS over the years, and a completely new system brings with it a unique set of challenges I wasn’t only throwing the old code away; I was throwing away the applied project... detail as we explore how to apply it to the design of the CMS (which you’ll learn about at the end of this chapter) Some of the tools and components I detail in this chapter are separate downloads from the core 4 framework; I have provided the current links and versions for your convenience 2 www.it-ebooks.info CHAPTER 1 I VISUAL STUDIO 2010 AND NET 4 I Note The Common Language Runtime (CLR) is Microsoft’s... Iterators, and Collections 2 14 Accessors and Mutators 216 Assembly Compilation 217 Compiling IronPython Code to a DLL 218 Compiling IronPython Code to an Executable 219 Building Scripting Capabilities into the CMS 220 Handling Script Files Between Tiers 223 Calling Scripts for a CMS Page 2 24 A Simple Scripting Example . IN .NET Pro ASP. NET 4 CMS Advanced Techniques for C# Developers Using the .NET 4 Framework Alan Harris Learn the latest features of .NET 4 to build powerful ASP. NET 4 web applications Pro this. of a CMS Page 37 Buckets 37 Embeddable Objects 39 Embeddable Permissions 41 Handling CMS Content 43 The Content Table 43 The ContentVersion Table 44 Assembling Content on Demand 44 How. Mode for Production 239 Removing the Server, X-Powered-By, and X-AspNet-Version Headers 241 Debugging Concepts 244 White-Box vs. Black-Box Debuggers 244 User Mode vs. Kernel Mode 245 Historical

Ngày đăng: 28/04/2014, 16:44

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan