Asp.net 是否设置默认路由url和属性路由?如何
我的RouteConfig文件是Asp.net 是否设置默认路由url和属性路由?如何,asp.net,asp.net-mvc,routing,asp.net-mvc-routing,asp.net-mvc-5,Asp.net,Asp.net Mvc,Routing,Asp.net Mvc Routing,Asp.net Mvc 5,我的RouteConfig文件是 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller =
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();
}
我的工作网址是
但是我想使用simple作为默认url,因为没有mapmvcattributteroutes,它可以正常工作
如何在同一个项目中使用这两种方法,如默认控制器操作必须是employee和index,然后单击route 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();
}
}