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.
Loading...
Related Quiz
- Imagine you're working on an e-commerce application using ASP.NET Core MVC. A user wants to view details of a product. Which component of the MVC pattern would be responsible for fetching the product details from the database?
- Which default folder in an ASP.NET Core web application is used to store and serve static files like CSS, JavaScript, and images?
- Which ASP.NET Core feature allows you to implement authentication and authorization logic to protect your Web APIs?
- What command would you typically use to create a new ASP.NET Core web application using the .NET Core CLI?
- Your company's security policy dictates that users must change their passwords every 60 days. How would you implement this requirement using ASP.NET Core Identity?