Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)

所需积分/C币:33 2015-03-23 02:30:28 8.89MB PDF
收藏 收藏 1
举报

The power of ASP.NET MVC 5 stems from the underlying ASP.NET platform. To make your ASP.NET MVC applications the best they can be, you need to fully understand the platform features and know how they can be used to build effective and elegant MVC framework applications. The ASP.NET platform provides
Contents at a glance About the author About the technical reviewer Part 1: Getting ready a Chapter 1: Putting the AsPNEt Platform in Context.a 3 Chapter 2: Pattern and tools primer 9 Part 2: the aspinet platform foundation n23 Chapter 3: The ASPNET Life Cycles ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 25 Chapter 4: Modules mamaaamaaaaaaaaaa mn 55 Chapter 5: Handlers ■■■■■■■ 79 Chapter 6: Disrupting the Request Life cycle ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■ 105 Chapter 7: Detecting Device Capabilities amman ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 129 Chapter 8: Tracing Requests.mama na159 Part 3: the Chapter 9: Configuration ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 179 Chapter 10: State Data ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 217 Chapter 11: Caching Data a g251 Chapter 12: Caching Content RREEIaS ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 273 CONTENTS AT A GLANCI Chapter 13: Getting Started with identitymmmma 297 Chapter 14: Applying ASPNeT Identity amn ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■ 333 Chapter 15: Advanced AsPNeT Identity tsanaaaaaaa 365 ndex n399 PART 1 Getting Ready CHAPTER 1 Putting the asP. NeT Platform in Context The asp. net platform was originally developed for use with Web Forms and support for the mvc framework was added later. The asp.net platform is full ofrich and useful features, but most guides to the Mvc framework assumed that programmers have experience in Web Forms development and already know what the platform is capable of doing. That was a reasonable assumption when the mvc framework was new, but a new generation of Asp.NEt developers has jumped right in with mvc without using Web Forms and-by implication-the features that the asP.net platform provides This book corrects the problem, detailing the features of the asP. NET platform for the MvC framework developer who has no Web Forms experience(and no desire to acquire any) Throughout this book, I show you how the ASP. NET platform underpins the mvc framework and how you can take advantage of the platform to improve your MvC applications. You dont need to know how the asp.nET platform works to build MvC framework applications, but you will want to know when you learn just how much functionality is available and how it can help simplify application development, customize the way that the MvC framework operates, and scale up applications to larger numbers of users, both for local and cloud-deployed applications Note This book is not an MVc framework tutorial, and assume you have a basic understanding of Mvc and web application development in general. If you are new to the Mvc framework, then start by reading my pro ASP NET Mvc 5 book, which is also published by Apress What s the aspnet platform ASP. NET was originally synonymous with Web Forms, which aims to make the web application development experience as similar as possible to developing a traditional desktop application and to abstract away the details of Htmlandhttp Web Forms has achieved remarkable market penetration despite having a reputation for producing hard-to maintain applications and being bandwidth hungry microsoft continually improves and updates web Forms-and it is still a widely used technology-but the broad development trend is away from abstraction and toward embracing the stateless nature of Http.ToremaincurrentinthewebdevelopmentworldMicrosoftextendedasp.netTo include the MvC framework and, more recently, SignalR and Web apI CHAPTER 1 PUTTING THE ASPNET PLATFORM IN CONTEXT These technologies have disparate natures. The MvC framework is an alternative to Web Forms for building complete web applications (one i assume you are familiar with if you are reading this book). signal uses an hTmL5 feature called web sockets to enable real-time communication between a browser and a server, and Web api is used to create web services and aPis that deliver json or Xml content For all their differences, the ASP.NET technologies share some common characteristics, and this is where the asP NET platform starts to emerge. Features that are common across ASP. NET-such as the need to receive and process Http requests for example-are implemented in a common foundation which results in the technology stack shown in Figure 1-1 ASP. NET Foundation Figure 1-1. The ASpNEt foundation The dotted line in the figure illustrates that some of the design decisions made when Web Forms was the only ASP.NET technology are still present in the ASP. NET foundation For the most part, this just means that there are some odd method names in the foundation apl, which i describe in part 2 of this book The asp.net platform doesnt just provide common features to the ASP.NET technology stack; it also provides a set of services that make it easier to write web applications, such as security, state data, and caching as illustrated by Figure 1-2. ASP. NET Services 卫 ASP. NET Foundation Figure 1-2. The ASP. NET services When using the MvC framework, you will usually consume these services from within controllers and models, but the services themselves are not part of the mvc framework and are available across the entire asp. net family of technologies CHAPTER 1 PUTTING THE ASPNET PLATFORM IN CONTEXT I have drawn the AsP.NEt services as being separate from the AsP. NET foundation, which makes them easier to describe but doesn't accurately reflect the fact almost all of the services are integrated into the functionality provided bythefoundationsThisisimportantbecausetheservicesrelyonthewaythatthefoundationhandleshttprequests in order to provide functionality to services, and it will start to make more sense once i get into the details of the ASP. NET request life cycle in Part 2 of this book The asp. nET platform is the combination of the foundation and the services, and using the asp. nET platform in MVC framework applications is the topic of this book, as illustrated by Figure 1-3 Model Controller View MVC Framework ASP. NET Foundation Figure 1-3. The relationship between the ASP. NET platform and the MvCframework Don't worry if the relationship between the MVC framework, the application components, and the asP.NEt latform dont make immediate sense everything will start to fall into place as you learn about how the platform works and the ieaturesit provides What do you need to know? This book is for developers who have experience in web application development using C# and the Mvc framework Youshouldunderstandthenatureofhttphtmlandcssandbefamiliarwiththebasicfeaturesofvisualstudio 2013(although i provide a quick primer for how i use Visual Studio in Chapter 2) You will find this book hard to follow if you don t have experience with the mvc framework, although there are plenty of examples that will help fill in the gaps. If you need to brush up on using the Mvc framework, then I suggest my Pro ASP. NET MVC 5 for MvC development and The Definitive Guide to HTML5 for detailed coverage of HTML and CSS What's the structure of this book? This book is split into three parts, each of which covers a set of related topics CHAPTER 1 PUTTING THE ASPNET PLATFORM IN CONTEXT Part 1: Getting ready Part 1 of this book provides the information you need to get ready for the rest of the book. It includes this chapter and a primer for the tools i use in this book and for the mvc pattern Part 2 The asPnet Platform Foundation Part 2 of this book takes you through the foundation features of the asP. NET platform, starting with the application and request life cycle and onto more advanced topics such as modules and handlers. This part of the book explains in detail how the asp.net platform handles requests and passes them to the mvc framework Part 3 The asP NEt services Part 3 of this book describes the services that the ASP. NET platform provides to developers for use in MVC framework applications. These services range from hidden gems such as the configuration service to performance optimizations, such as data and content caching i also describe the new asp. net identity system which is used to manage user authentication and authorization Are There Lots of Examples? There are loads of examples I demonstrate every important feature with code examples that you can add to your own projects, and i list the contents of every file in every example so that you get a complete picture of how each feature works. I use two code styles for examples. The first is when I list a complete file, as shown in Listing 1-1 Listing 1-1. A Complete listing g using Microsoft AspNet Identity; using Microsoft AspNet Identity. EntityFramework; using Microsoft AspNet Identity. Owin; using Microsoft Owin; using Users. Models namespace Users. Infrastructure i public class AppUserManager UserManager<AppUser> i public AppUserManager(IUserStore<AppUser> store base(store)[ public static AppUserManager Create( Identity FactoryOptions<AppUserManager> options IOwin Context context)i AppIdentityDbContext db= context. Get<AppIdentityDbContext>; AppUserManager manager new AppUserManager(new UserStore<AppUser>(db)) return manager; CHAPTER 1 PUTTING THE ASPNET PLATFORM IN CONTEXT with complete listings; then, as l make changes to show you different features, I switch to partial listings, such ag fer This listing is taken from Chapter 13-don't worry about what it does at the moment. I usually start the chapt Listing 1-2 Listing 1-2. A Partial listing return HttpContext. GetOwinContext(.GetUserManager<AppUserManager o; This listing is also taken from Chapter 13 and shows a section of the file from Listing 1-1. I highlight the changes that I have made or the statements i want to draw your attention to. Using partial listings helps avoid endless repetitions of files that have small changes and lets me pack in more examples per page and per chapter. Where Can You Get the Example Code? All of the example code is contained in the text of this book, but you don' t have to type it in yourself. You can download a complete set of example projects, organized by chapter, without charge from Apress. com What software do you need for this book? The most important software you need for this book is visual Studio 2013, which contains everything you need to get started, including a built-in application server for running and debugging Mvc applications, an administration-free edition of SQL Server for developing database-driven applications, tools for unit testing, and, of course, a code editor compiler and debugger. There are several editions of Visual Studio, but i will be using the one that Microsoft makes available free of charge, called Visual Studio Express 2013 for Web. Microsoft adds some nice features to the paid-for editions of visu Studio, but you will not need them for this book, and all of the figures that you see throughout this book have been takenusingtheExpresseditionwhichyoucandownloadfromWww.microsoft.com/visualstudio/eng/products/ visual-studio-express-products. There are several versions of Visual Studio 2013 Express each of which is used for a different kind of development. Make sure that you get the Web version, which supports ASP.NET applications I follow a specific approach to creating AsP. NET projects: I dont use the predefined templates that Microsoft but the benefit is that you end up with a much better understanding ol now an application fits together I provide o g provides, preferring to explicitly add all of the packages that i require. This means more work is required to get set u primer in Chapter 2 that gives an example of what you can expect. Tip Visual Studio includes NuGet for downloading and installing software packages. I use Nuget throughout this book. So that you are sure to get the results that I demonstrate, I always specify the version of the Nuget package you requireIfyouareindoubtdownloadthesourcecodeforthisbookfromwww.apress.comwhichcontainscomplete projects for each chapter. Preparing Visual Studio Visual Studio Express contains all the features you need to create, test, and deploy an mvc framework application, but some of those features are hidden away until you ask for them. To enable all of the features, select Expert Settings from the visual Studio Tools Settings menu.

...展开详情
试读 127P Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)
立即下载 低至0.43元/次 身份认证VIP会员低至7折
    一个资源只可评论一次,评论内容不能少于5个字
    chonghanyu 有英文基础的可以下载。不是中文的。
    2017-06-11
    回复
    friendll1 英文版的,没有英文基本还是洗洗睡了吧
    2015-07-27
    回复
    关注 私信 TA的资源
    上传资源赚积分,得勋章
    最新推荐
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014) 33积分/C币 立即下载
    1/127
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第1页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第2页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第3页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第4页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第5页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第6页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第7页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第8页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第9页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第10页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第11页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第12页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第13页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第14页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第15页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第16页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第17页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第18页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第19页
    Pro ASP.NET MVC 5 Platform(Apress,Adam.Freeman,2014)第20页

    试读已结束,剩余107页未读...

    33积分/C币 立即下载 >