I have a custom route inside an area:
[RouteArea("MyArea")]
public class MyController: Controller
{
[Route("~/my-action")]
public ActionResult MyAction()
{
return View();
}
}
Before adding the Route and RouteArea attributes, I accessed this action through the following route:
~/MyArea/MyController/MyAction
Now that I added this attributes, I am able to access it just through this:
~/my-action
I used to have an ActionLink which was pointing to this action and it looked like this:
@Html.ActionLink("Link To My Action", "MyAction", "My", new { Area = "MyArea" }, new { })
Now this ActionLink is no longer working. How can I fix it?
ActionLinkwould never have worked - you controller is namedMyControllerso it would have need to be@Html.ActionLink("Link To My Action", "MyAction", "My", new { Area = "MyArea" }, new { })RouteConfig.csfile like this:routes.MapMvcAttributeRoutes()in theRegisterRoutesmethod?Traditional RoutingandAttribute Routing- perhaps try to remove theTraditionalone if you have any traces of it, and just try to go withAttributes?