This is my controller
[Authorize]
[RoutePrefix("service")]
public class ServiceController : BaseController
{
[HttpGet]
[Route("~/services")]
public ActionResult Index();
[HttpPost]
[Route]
public JsonResult Index(int rowCount, string search);
[HttpGet]
[Route("new/{subcategoryID}")]
public ActionResult New(int subcategoryID);
[HttpGet]
[Route("edit/{serviceID}")]
public ActionResult Edit(int serviceID);
[HttpPost]
[Route("edit")]
[ValidateJsonAntiForgeryToken]
public JsonResult Edit(ServiceJson service);
[HttpDelete]
[Route("delete")]
public ActionResult Delete(int serviceID);
}
When I call
@Url.Action("Edit", "Service", new { serviceID = service.ServiceID})
in my view I get
service/edit?serviceID=12
instead of
service/edit/12
Why is this happening? There is no other GET action on this controller that is named Edit. This is driving me crazy for some time now.
The attribute routing should scan the controllers and do the automapping of routes. Why is it falling back to query string if there is obviously an action with this parameter?
I would also like to note that if I manually enter address
service/edit/12
i will get redirected to the appropriate page.