You're working on an e-commerce platform and need to create a route for a product details page which takes a product ID as a parameter. Using attribute routing, how would you set up this route?

  • [Route("products/details/{id:int}")]
  • [HttpGet("products/details/{productID}")]
  • [Route("products/details")]
  • [Route("products/{id}")]
To set up a route for a product details page with a product ID parameter using attribute routing, you should use [Route("products/details/{id:int}")]. The ':int' constraint specifies that the 'id' parameter must be an integer.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *