i have following route method:
[httpget] [route("company/employees/{name}")] public actionresult details(string name)
i want access employee name property of "john" making request to
company/employees/john
but route works if type:
company/employees?name=john
how can fix this?
edit:
this route config (inside area)
context.maproute( "company_default", "company/{controller}/{action}/{id}", new { controller = "employees", action = "index", id = urlparameter.optional }, namespaces: new[] { "mysite.areas.company.controllers" } );
as say, default route have same sturture custom contoller route. becouse {id}
param optional.
if want use route should define custom route in routeconfig before default route , rid of route
attribute on controller:
context.maproute( "detailscustom", "company/employees/{name}", new { controller = "employees", action = "details"}, namespaces: new[] { "mysite.areas.company.controllers" } );
Comments
Post a Comment