I have action in controller with ASP.NET MVC 5 attribute routing.
[RoutePrefix("ControllerName")]
public class MyController : Controller
{
[Route("ActionName")]
public ActionResult Index()
{
return View();
}
}
When I try to get url in action like this (Controller.Url)
Url.Action("Index", "My")
I get
/My/Index
When I do the same in View (It's WebViewPage.Url),
@Url.Action("Index", "My")
I get
/ControllerName/ActionName
How can I get /ControllerName/ActionName in action?