concept default value in category asp.net

appears as: default values, default value, The default values, default values
ASP.NET Core in Action, Second Edition

This is an excerpt from Manning's book ASP.NET Core in Action, Second Edition.

As well as the basic elements of literals and route parameter segments, route templates have extra features that give you more control over your application’s URLs. These features let you have optional URL segments, provide default values when a segment isn’t specified, or can place additional constraints on the values that are valid for a given route parameter. This section takes a look at these features, and ways you can apply them.

ASP.NET Core in Action

This is an excerpt from Manning's book ASP.NET Core in Action.

The ability to set default values for URL segments when they aren’t explicitly provided can be useful for allowing multiple URLs that point to the same action method. You saw it in table 5.1, where the List action was inferred from the /currencies URL. A common convention used by default in most ASP.NET Core MVC applications is that the homepage of your application is invoked using the HomeController.Index() action method. With the default conventions, any of the following URL paths will invoke this action:

5.3.4. Defining default values and constraints using anonymous objects

All of the examples shown in this section on route templates have defined default values and route constraints inline as part of the route template, using the {action= view} and {id:int} syntax.

Listing 5.3. Defining route constraints and default values using anonymous types
routes.MapRoute( name: "default", template: "{controller}/{currency}/{action}", #1 defaults: new { #2 currency="USD", #2 action="View" #2 }, #2 constraints: new { #3 currency = new LengthRouteConstraint(3) #3 }); #3 #1 Required. The raw route template, without defaults or constraints #2 Optional. The default values to use when a parameter is missing #3 Optional. Constraints to apply to route parameters !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":2,\"ch\":62},{\"line\":2,\"ch\":64}],[{\"line\":11,\"ch\":0},{\"line\":11,\"ch\":2}],[{\"line\":3,\"ch\":62},{\"line\":3,\"ch\":64}],[{\"line\":4,\"ch\":62},{\"line\":4,\"ch\":64}],[{\"line\":5,\"ch\":62},{\"line\":5,\"ch\":64}],[{\"line\":6,\"ch\":62},{\"line\":6,\"ch\":64}],[{\"line\":12,\"ch\":0},{\"line\":12,\"ch\":2}],[{\"line\":3,\"ch\":62},{\"line\":3,\"ch\":64}],[{\"line\":4,\"ch\":62},{\"line\":4,\"ch\":64}],[{\"line\":5,\"ch\":62},{\"line\":5,\"ch\":64}],[{\"line\":6,\"ch\":62},{\"line\":6,\"ch\":64}],[{\"line\":12,\"ch\":0},{\"line\":12,\"ch\":2}],[{\"line\":3,\"ch\":62},{\"line\":3,\"ch\":64}],[{\"line\":4,\"ch\":62},{\"line\":4,\"ch\":64}],[{\"line\":5,\"ch\":62},{\"line\":5,\"ch\":64}],[{\"line\":6,\"ch\":62},{\"line\":6,\"ch\":64}],[{\"line\":12,\"ch\":0},{\"line\":12,\"ch\":2}],[{\"line\":3,\"ch\":62},{\"line\":3,\"ch\":64}],[{\"line\":4,\"ch\":62},{\"line\":4,\"ch\":64}],[{\"line\":5,\"ch\":62},{\"line\":5,\"ch\":64}],[{\"line\":6,\"ch\":62},{\"line\":6,\"ch\":64}],[{\"line\":12,\"ch\":0},{\"line\":12,\"ch\":2}],[{\"line\":7,\"ch\":62},{\"line\":7,\"ch\":64}],[{\"line\":8,\"ch\":62},{\"line\":8,\"ch\":64}],[{\"line\":9,\"ch\":62},{\"line\":9,\"ch\":64}],[{\"line\":13,\"ch\":0},{\"line\":13,\"ch\":2}],[{\"line\":7,\"ch\":62},{\"line\":7,\"ch\":64}],[{\"line\":8,\"ch\":62},{\"line\":8,\"ch\":64}],[{\"line\":9,\"ch\":62},{\"line\":9,\"ch\":64}],[{\"line\":13,\"ch\":0},{\"line\":13,\"ch\":2}],[{\"line\":7,\"ch\":62},{\"line\":7,\"ch\":64}],[{\"line\":8,\"ch\":62},{\"line\":8,\"ch\":64}],[{\"line\":9,\"ch\":62},{\"line\":9,\"ch\":64}],[{\"line\":13,\"ch\":0},{\"line\":13,\"ch\":2}]]"} !@%STYLE%@!