Skip to content

Show Area name as part of the route path to avoid confusion #15

Open
@thiagomajesk

Description

If you have an controller inside a area like this:

[Area("Products")]
public class HomeController : Controller
{
    [HttpGet("[controller]/[action]/{id}")]
    public IActionResult Index(int id) => Ok();
    
    public IActionResult Show(int id) => Ok();    
}

You'll have routes mapped for /Home/Index and /Products/Home/Show.

¹{ Area = "Products", Path: "/Home/Index" },
 { Area = "Products", Path: "/Home/Show" }

¹ This is missleading since the route is not acessible through /Products/Home/Index due to attribute override.

The solution for me would be to include area into the route path. It makes sense to me because this already happens if you put an attribute route like: HttpGet("[area]/[controller]/[action]") on top of an action.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions