Building RESTful Web Services with .NET Core
Developing Distributed Web Services to improve scalability with .NET Core 2.0 and ASP.NET Core 2.0
Gaurav Aroraa
Tadit Dash
BIRMINGHAM - MUMBAI
Building RESTful Web Serviceswith .NET Core
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Aaron Lazar
Acquisition Editor: Denim Pinto
Content Development Editor: Anugraha Arunagiri
Technical Editor: Jash Bavishi
Copy Editor: Safis Editing
Project Coordinator: Ulhas Kambali
Proofreader: Safis Editing
Indexer: Mariammal Chettiyar
Graphics: Tania Dutta
Production Coordinator: Shantanu Zagade
First published: May 2018
Production reference: 1290518
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78829-157-6
www.packtpub.com
To my mother, Late Smt. Santosh, and to the memory of my father, Late Sh. Ramkrishan, for their sacrifices and for exemplifying the power of determination. To my youngest sister Late Baby Kanchan for her love and always being my lucky charm.
Gaurav Aroraa
To my grandfather late Ganeswar Tripathy, for consistently motivating me.
To my father, Dr. Gobinda Chandra Dash, and mother, Mrs. Sasmita Tripathy, for whatever they have sacrificed in their life to build me.
Tadit Dash
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the authors
Gaurav Aroraa has an M.Phil in computer science. He is a Microsoft MVP, a lifetime member of Computer Society of India (CSI), an advisory member of IndiaMentor, certified as a scrum trainer/coach, XEN for ITIL-F, and APMG for PRINCE-F and PRINCE-P. Gaurav is an open source developer, a contributor to TechNet Wiki, and the founder of Ovatic Systems Private Limited. In 20+ years of his career, he has mentored thousands of students and industry professionals. You can tweet Gaurav on his Twitter handle @g_arora.
To my wife, Shuby Arora, and my angel (daughter), Aarchi Arora, who permitted me to steal time for this book from the time I was supposed to spend with them. Thanks to the entire Packt team, especially Ulhas, Vikas Tiwari, Anugraha Arunagiri, and Jash Bavishi, whose coordination and communication during the period was tremendous, and Denim Pinto, who introduced me for this book.
Tadit Dash is a senior software engineer and a hardcore tech community contributor. Due to his exceptional contribution to the technical community, Microsoft has awarded him with the Microsoft Most Valuable Professional accolade since 2014. CodeProject has awarded him the CodeProject MVP accolade (the first from Odisha). For his constant mentorship, IndiaMentor featured him as a young mentor on their site. He was a featured speaker at DevTechDay Nepal and C# Corner Annual Conference, India. You can follow him on Twitter: @taditdash.
To Utkal Techies Forum members Suvendu Giri, Pravasini Sahoo, Suraj Sahoo, Surya Barik, Abhijit Pattnaik, Sourav Nanda, Jayant Rajwani, Ramesh Barik; my friends Manas Pritam, Deepak Mahapatra; my cousins Lipsa, Aurobin, Titiksha, Juthika, Amrit, Sanvi, Anushka, Swostik; my mentor Gaurav Arora; and the Packt team, Denim Pinto, Vikas Tiwari, Anugraha Arunagiri, and Jash Bavishi.
About the reviewer
Hansamali Gamage is an experienced professional and Microsoft MVP in Visual Studio and Technologies from Sri Lanka. She possesses 5+ years of experience in .NET stack and Azure-related services. She is a frequent speaker at local and global tech events. She is a tech enthusiast and an award-winning writer on the Microsoft Tech Net forum. She works at TIQRI, previously known as Exilesoft, which is technology-focused software engineering company that has offices in Scandinavia, Asia, and Australia.
I would like to thank my loving family for their continuous help and support.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
This book will take the readers through the design of RESTful web services and leverages the ASP.NET Core Framework to implement these services. Starting from the basics of the philosophy behind REST, the readers will go through the steps of designing and implementing an enterprise-grade RESTful web service. Taking a practical approach, each chapter provides code samples that they can apply to your own circumstances. It brings forth the power of the latest .NET Core release, working with MVC. It then goes beyond the use of the framework to explore approaches to tackle resilience, security, and scalability concerns. The readers will learn techniques to deal with security in Web APIs and discover how to implement unit and integration test strategies. Finally, the book ends by walking you through building a .NET client for your RESTful web service, along with some scaling techniques.
Next page