My RouteConfig file is
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Employee", action = "Index", id = UrlParameter.Optional }
);
My controller is
[Route("EMS/{Employee}")]
public ActionResult Index()
{
return View();
}
my working url is http://localhost:6628/EMS/Employee
but i want to use simple http://localhost:6628 as my default url as without MapMvcAttributeRoutes() it was working fine
How can i use both of them in same project like default controller action must be employee and index and on click route url EMS/Employee working like this
<td>
<input type="button" id="ROUTE" value="ROUTE" onclick="location.href='@Url.Action("Employee", "EMS")'" class="btn-info" />
</td>
If the controller for example is EmployeeController
public class EmployeeController {
[HttpGet]
[Route("")] //Matches GET /
[Route("EMS/Employee")] //Matches GET EMS/EMployee
public ActionResult Index() {
return View();
}
}
You can use multiple routes on the actions.