You're tasked with building a new feature in an ASP.NET Core application where each user profile should be accessible via a URL like /users/{username}. How can attribute routing facilitate this?

  • Use [Route("users/{username}")] on the action method
  • Modify the appsettings.json file
  • Create a new middleware component
  • Add a user-profile route in Startup.cs
In ASP.NET Core, attribute routing allows you to define custom routes for your controllers and action methods. By using the [Route] attribute with the desired route template, you can specify that the user profile should be accessible via /users/{username}.
Add your answer
Loading...

Leave a comment

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