Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 是否设置默认路由url和属性路由?如何_Asp.net_Asp.net Mvc_Routing_Asp.net Mvc Routing_Asp.net Mvc 5 - Fatal编程技术网

Asp.net 是否设置默认路由url和属性路由?如何

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 =

我的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();
    }
我的工作网址是

但是我想使用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();
    }
}