Taking ASP.NET Core further

Now that you've seen the basics of how models, views, and controllers work together to provide a web application, let's look at some common scenarios, such as passing parameters and annotating models.

Passing parameters using a route value

Back in the HomeController class, add the following action method. It uses something called the default model binder to automatically match the id passed in the route to the parameter named id in the method.

Tip

Model binders are very powerful, and the default one does a lot for you. For advanced scenarios, you can create your own by implementing the IModelBinder interface, but that is beyond the scope of this book.

Inside the method, we check to see whether the id is null, and if so, ...

Get C# 6 and .NET Core 1.0: Modern Cross-Platform Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.