I have the following route to my method:
[HttpGet]
[Route("Company/Employees/{name}")]
public ActionResult Details(string name)
I want to access the employee with a name property of "John" by making a request to
Company/Employees/John
But now the route only works if I type:
Company/Employees?name=John
How can I fix this?
Edit:
This is my route config (inside an area)
context.MapRoute(
"Company_default",
"Company/{controller}/{action}/{id}",
new { controller = "Employees", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "MySite.Areas.Company.Controllers" }
);
{name}part with{id}?idin the route and in the parameter variable name