Search code examples
asp.net-mvcrazorattributerouting

Html.Action with attribute routing


My route attribute is like below

   [RouteArea("Settings")]
   [RoutePrefix("Stores")]
 public class SettingsMallStoresController : Controller
    {
    [HttpGet]
    [Route("ExistingStores/{Permalink}")]
    public ActionResult GetExistingStoreBranchesForSelectedHO(string permalink)
    {
         return View("ExistingStoreBranches");
    }
}

I am trying to call this action from View using @html.action

@Html.Action("Settings/Stores/ExistingStores/{Permalink}",new{permalink=Somevalue})

Can't make it work in anyway.Please help


Solution

  • This One worked for me. Still not sure how to use Attribute routing instead of directly calling controller action. Better way is appriciable @Html.Action("GetExistingStoreBranchesForSelectedHO", new { Controller = "SettingsMallStores", Action = "GetExistingStoreBranchesForSelectedHO" })