asp.net mvc - using Areas in MVC5 -


i trying achieve routings follow:

etc...

i ideas of using 'areas' , want separate codes using areas. so, created areas structure following screnshot enter image description here

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

Popular posts from this blog

python - argument must be rect style object - Pygame -

c++ - Qt setGeometry: Unable to set geometry -

php - Zend Framework / Skeleton-Application / Composer install issue -