liveBook · Manning

Strongly-typed id

As explained in ASP.NET Core in Action, 3e

A strongly typed ID is a domain-specific identifier type that restricts an identifier's representation and conversion to that type.

A strongly typed ID gives an identifier its own domain-specific type instead of treating it as a plain integer or string. In a minimal API, ASP.NET Core can bind route, query, or header values to that type when it exposes a suitable TryParse method. section 7.2

ProductId from a route

An endpoint accepting ProductId can handle /product/p123. TryParse checks that the value starts with p and that the remainder is an integer. Successful parsing creates ProductId(123); invalid input makes binding fail and returns HTTP 400. section 7.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines TryParse-based binding, successful conversion, and 400 responses, but does not cover broader identifier design.
Examples
Demonstrates ProductId parsing values such as p123 through a /product/{id} route.
What you can do after
Build it from scratch by implementing TryParse on an identifier and accepting it as an endpoint parameter.
How it connects
Connects strongly typed IDs with model binding, minimal APIs, route values, and TryParse.

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.