liveBook · Manning

Converter

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

A type converter is a .NET conversion component or convention that converts values between specified types, including converting textual input to another type.

A converter changes a value from one type to another. During Razor Pages model binding, request values arrive as strings, and the model binder converts them to primitive .NET types or custom types supported by TryParse or TypeConverter. section 16.2.1

Binding a number

A handler can accept an integer parameter such as number, then calculate number * number. The incoming route value is textual, but model binding converts it to int before the handler runs. section 16.2.1

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

How deep it goes
Identifies primitive types, TryParse, and TypeConverter as supported paths without detailing converter implementation.
Examples
Uses a Razor Page handler that accepts an integer number and calculates its square.
What it assumes
Assumes familiarity with Razor Pages handlers and request values while treating incoming values as strings.
What you can do after
Apply model binding to receive converted primitive values and recognize custom types supported by TryParse or TypeConverter.
How it connects
Connects model binding with simple types, TryParse, TypeConverter, route values, and form values.

Also explained in

Compare how 4 books explain converter →

Related concepts

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.