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}.
Loading...
Related Quiz
- When securing your ASP.NET Core Web APIs, which authentication approach uses a compact, URL-safe means of representing claims to be transferred between two parties?
- The configuration values in __________ will override the values from appsettings.json when deploying an application to production.
- In what scenario might you use the _ViewImports.cshtml file in conjunction with Razor Layout Views?
- The MVC folder structure typically includes three main folders: Controllers, Views, and _________.
- Dependency injection in ASP.NET Core MVC allows services to be injected into controllers via their _________.