If you have a URL like /products/5, what would be a suitable route template to capture the product's id?
- /products/{id:int}
- /products/{id}
- /products/{product_id}
- /products?id=5
To capture the product's id from a URL like /products/5, you can use the route template /products/{id}. The {id} segment is a placeholder for the product's id, and the :int constraint ensures that it must be an integer value. This allows you to retrieve and process the id as a parameter in your controller action.
Loading...
Related Quiz
- Unlike the traditional ASP.NET which relied on System.Web.dll, ASP.NET Core operates on a set of granular and modular _________ packages.
- If you wish to apply a unique constraint on a column using the Fluent API in Entity Framework Core, which method should you use inside OnModelCreating?
- How does the "Worker Service" template in ASP.NET Core differ from the traditional web application templates?
- One of the features of ASP.NET Core is its ability to run on _________ platforms.
- You are creating a website and want to add a folder for storing images, scripts, and CSS files. Which default folder in ASP.NET Core would you typically use?