设置默认路由 url 和属性路由?如何

set Default routing url and attribute route ? how to

我的 RouteConfig 文件是

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapMvcAttributeRoutes();
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Employee", action = "Index", id = UrlParameter.Optional }
        );

我的控制器是

 [Route("EMS/{Employee}")]
    public ActionResult Index()
    {
        return View();
    }

我的工作 url 是 http://localhost:6628/EMS/Employee

但我想使用简单的 http://localhost:6628 作为我的默认 url 因为没有 MapMvcAttributeRoutes() 它工作正常

我如何在同一个项目中同时使用它们,例如默认控制器操作必须是员工和索引,并且在点击路径上 url EMS/Employee 像这样工作

  <td>
    <input type="button" id="ROUTE" value="ROUTE"   onclick="location.href='@Url.Action("Employee", "EMS")'" class="btn-info" />
                        </td>

如果控制器是 EmployeeController

public class EmployeeController {    
    [HttpGet]
    [Route("")] //Matches GET /
    [Route("EMS/Employee")] //Matches GET EMS/EMployee
    public ActionResult Index() {
        return View();
    }
}

您可以在操作上使用多条路线。