没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
395页
Like all of us in this industry, I have been through a ton of programming or framework-centric books in my career as a developer. Without a doubt, my favorite type has always been a recipe-style book. It might be my low attention span or simply my urge to solve problems rather than read through abstract discussions, but I really enjoy the no-nonsense, straight-to-the-point format of such publications.
资源推荐
资源详情
资源评论
Wojcieszyn
Shelve in
.NET
User level:
Intermediate–Advanced
www.apress.com
SOURCE CODE ONLINE
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
ASP.NET Web API 2 Recipes
ASP.NET Web API 2 Recipes gives you the code and the knowledge to deal with the scenarios
you are likely to encounter when developing line-of-business applications with the popular
and powerful ASP.NET Web API framework. Each recipe is presented in a succinct problem/
solution format and is accompanied by a working code sample and an in-depth explanation,
to help you understand the concept quickly and apply it to your own application.
ASP.NET Web API 2 Recipes will show you how to:
• Use Web API with a vast array of .NET application development
tools and external libraries
• Build stable, robust ASP.NET Web API solutions on top of the
ASP.NET runtime, as well as outside of IIS
• Take advantage of HTTP as a true application protocol,
by embracing ASP.NET Web API’s rich HTTP programming model
• Explore the power of the OWIN pipeline
• Learn how to customize and configure every aspect of ASP.NET
Web API, to suit your business needs and requirements
• Benefit from unit testing your Web API services, routing and
components, as well as integration testing of the entire Web API solution
• Discover the secrets of building loosely coupled, reusable
Web API components and extensions
• Integrate a realtime component into your Web API
ASP.NET Web API Recipes is for application developers who are creating line-of-business
applications using .NET Framework 4.5 with Visual Studio 2012 or Visual Studio 2013.
Experience with ASP.NET Web API is not assumed, but you’ll have experience building
ASP.NET applications and working with HTTP APIs.
Find out how you can build custom web services with ASP.NET Web API more efficiently than
ever with ASP.NET Web API 2 Recipes.
RELATED
9781430 259800
54999
ISBN 978-1-4302-5980-0
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
v
Contents at a Glance
About the Author �������������������������������������������������������������������������������������������������������������� xxv
About the Technical Reviewer ���������������������������������������������������������������������������������������� xxvii
Acknowledgments ����������������������������������������������������������������������������������������������������������� xxix
Introduction ��������������������������������������������������������������������������������������������������������������������� xxxi
Chapter 1: Web API in ASP�NET ■ ������������������������������������������������������������������������������������������1
Chapter 2: ASP�NET Web API Outside of IIS ■ ����������������������������������������������������������������������33
Chapter 3: Routing ■ �����������������������������������������������������������������������������������������������������������57
Chapter 4: Content Negotiation and Media Types ■ ������������������������������������������������������������91
Chapter 5: Configuration and Customization ■ �����������������������������������������������������������������129
Chapter 6: Embrace HTTP with ASP�NET Web API ■ ����������������������������������������������������������171
Chapter 7: Exceptions, Troubleshooting, and Documenting ■ ������������������������������������������205
Chapter 8: Cross Domain and Push Communication ■ �����������������������������������������������������235
Chapter 9: Dependency Injection ■ �����������������������������������������������������������������������������������269
Chapter 10: Securing an ASP�NET Web API Service ■ �������������������������������������������������������283
Chapter 11: Testing Web API Services ■ ���������������������������������������������������������������������������317
Chapter 12: OData ■ ����������������������������������������������������������������������������������������������������������347
Index ���������������������������������������������������������������������������������������������������������������������������������365
xxxi
Introduction
Like all of us in this industry, I have been through a ton of programming or framework-centric books in my career as
a developer. Without a doubt, my favorite type has always been a recipe-style book. It might be my low attention span
or simply my urge to solve problems rather than read through abstract discussions, but I really enjoy the no-nonsense,
straight-to-the-point format of such publications.
I started working with Web API back when it was still WCF Web API. I started blogging about it in the early beta
days of the framework, at the beginning of 2012, at which time the name had already changed to ASP.NET Web API.
Since then I have produced almost 100 blog posts on virtually all aspects of working with ASP.NET Web API, written a
fair share of technical articles, been involved in a number of open-source initiatives focused around the framework,
and been a speaker at plenty of events. But most importantly, I have grown to know Web API better than my own
backyard.
I had some really wonderful feedback from readers and the amazing Web API community, so at some point I
started thinking about producing a recipe-style book, as it would feel like a natural extension of the material from
the blog. A number of plans and approaches were drafted and discussed, and things eventually came to fruition last
winter, when this book was ocially announced.
It has never been my intention to write an A-Z compendium or reference book about ASP.NET Web API. Instead,
I reveled in the opportunity to use the problem-solution format of the recipe-style book. In my mind, it makes the
book a much more enjoyable read, as you can cherry-pick the things you are interested in, rather than go through the
entire book in a linear fashion.
You will not find theoretical divagations about architecture or abstract academic discussions about REST in
this book. Instead, I focus on the problems stated in each recipe and how to solve them with ASP.NET Web API.
The book dissects what is going on under the hood in the framework and shows you how to push ASP.NET Web
API to its absolute limits. It is also a framework-centric book; it focuses on how to do things specifically with
ASP.NET Web API 2.
Each of the 103 recipes in the book has dedicated source code illustrating the technique or problem discussed in
the recipe. To make it easier to follow the book in a non-linear fashion, the solutions are not dependent on each other.
Each example is simple, straight to the point, and entirely self-contained. is allows for the important bits to clearly
stand out.
Due to the nature of the format of the book, the space available for each recipe is constrained, and as such, some
of the topics cannot be covered in depth. In those cases, I lay out the basics to help you get started, and then point to
extra resources and further reading.
ere were many recipe-style books that helped me in my career, and I sincerely hope that this book will help
you become a better ASP.NET Web API programmer, too. If at least a single recipe helps you avoid some headache
that the framework might have given you before, I will be absolutely thrilled.
1
Chapter 1
Web API in ASP.NET
This chapter discusses using ASP.NET Web API on top of IIS, within the ASP.NET runtime. The recipes covered in this
chapter deal with ASP.NET runtime specifics and, unless noted otherwise, the solutions presented here cannot be
extended onto other Web API hosts.
You will learn how to do the following:
Use ASP.NET Web API in the same process as ASP.NET MVC or ASP.NET Web Forms •
(Recipes 1-1 and 1-2)
Deal with HTML forms and validation (Recipes 1-3 and 1-6)•
Link between MVC and Web API controllers (Recipe 1-4)•
Use scaffolding to rapidly bootstrap ASP.NET Web API projects (Recipe 1-5)•
Introduce ASP.NET-based CSRF (Cross-Site Request Forgery) protection to your Web API •
(Recipe 1-7)
Work with traditional ASP.NET sessions in ASP.NET Web API (Recipe 1-8)•
On the other hand, all of the host-agnostic features of Web API (routing, model binding, content negotiation,
security, exception handling, and many others) are covered in detail in the upcoming chapters.
1-1. Add ASP.NET Web API to an MVC Application
Problem
You would like to integrate ASP.NET Web API into your ASP.NET MVC project.
Solution
ASP.NET Web API used to be automatically bundled in MVC project templates in Visual Studio 2012. Since Visual
Studio 2013, you compose your ASP.NET web application using the new One ASP.NET project wizard, based on
Microsoft’s concept of a unified ASP.NET platform, where you can select the relevant components, such as MVC and
Web API. This is shown in Figure 1-1.
剩余394页未读,继续阅读
资源评论
- qq_273378132016-03-27再增加100下载积分,即可升级到下一级
zhaoyun115
- 粉丝: 12
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功