asp.net mvc - using Areas in MVC5 -
i trying achieve routings follow:
- http://example.com/admin/index
- http://example.com/application/index
- http://example.com/customers/index
etc...
i ideas of using 'areas' , want separate codes using areas. so, created areas structure following screnshot
and code in applicationarearegistration.cs is
public override string areaname { { return "application"; } } public override void registerarea(arearegistrationcontext context) { context.maproute( "application_default", "application/{controller}/{action}/{id}", new { action = "index", id = urlparameter.optional } ); }
however, cannot achieve route want
http://example.com/application/index
in stead of becomes, http://example.com/application/application/index
i tried change default routing without {controller} in arearegistration
context.maproute( "application_default", "application/{action}/{id}", new { action = "index", id = urlparameter.optional } );
but got, controller required area.
i know can http://example.com/application/index if put controller in root controllers folder. means couldn't group codes areas anymore , seprated across mvc folders.
what know is, whether can achieve want using areas or trying impossible?
you need add default controller name route mvc understands put in controller route value when take out of url.
public override void registerarea(arearegistrationcontext context) { context.maproute( "application_default", "application/{action}/{id}", new { controller = "application", action = "index", id = urlparameter.optional } ); }
Comments
Post a Comment