Book Image

ASP.NET Core and Angular 2

By : Valerio De Sanctis
Book Image

ASP.NET Core and Angular 2

By: Valerio De Sanctis

Overview of this book

<p>Writing code is about striking a balance between maintainability and productivity—how quickly you can write it against how much more you have to write in the future. This is a guide to doing just that by combining the impressive capabilities of ASP.NET Core and Angular 2. It shows you how to successfully manage an API and use it to support and power a dynamic single-page application.</p> <p>We'll show you how to construct your data model and manage routing and redirects before wrapping it up and styling it, all with the help of ASP.NET and Angular 2. You'll also learn how to optimize your application for SEO, check and secure any vulnerabilities, implement a viable authentication mechanism and, last but not least, use the proper tools and strategies for successful deployment. From readable URIs to OData retrieval and authentication patterns, we'll make sure you have all the technical knowledge you need and, more importantly, bring it all together so you can focus on what's important: a high-quality application that performs for users.</p>
Table of Contents (16 chapters)
ASP.NET Core and Angular 2
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Understanding routes


In Chapter 1, Getting Ready, we acknowledged the fact that the ASP.NET Core pipeline has been completely rewritten in order to merge the MVC and WebAPI modules into a single, lightweight framework to handle both worlds. Although this certainly is a good thing, it comes with the usual downside that we need to learn a lot of new stuff. Handling routes is a perfect example of this, as the new approach defines some major breaking changes from the past.

Defining routing

The first thing we should do is give out a proper definition of what routing actually is.

To cut it simple, we could say that URL routing is the server-side feature that allows a web developer to handle HTTP requests pointing to URIs not mapping to physical files. Such techniques could be used for a number of different reasons, including the following:

  • Giving dynamic pages semantic, meaningful, and human-readable names in order to advantage readability and/or search-engine optimization (SEO)

  • Renaming or moving...