I m using attribute routing feature of Asp .Net Mvc. My first action is like below which is placed in SurveyController
[Route("{surveyName}")]
public ActionResult SurveyIndex()
{
return View();
}
And my second action is like below which is placed in MainCategoryController
[Route("{categoryUrlKey}")]
public ActionResult Index(string categoryUrlKey)
{
return View();
}
I'm not using convention based routing. Below is my RouteConfig.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
routes.MapAttributeRoutes();
}
Now the problem is when i click to a survey it redirects to the MainCategory/Index route. I know it is because of same route pattern but i cant change this into another thing. how can I handle this situation? Thanks