MVC 3 AREAS - Hierarchial workflows
For the project that I am working on, we have companies. Companies have contacts and facilities. Based on the business rules, the flow is you select a company to access the contacts or facilities.
EDIT: Entities are companies, facilities and contacts.
As each entity has it's own workflows, so they all have their one ARE开发者_JS百科A in the code. What would be a clean way to make sure tha the routing url would be something like below:
/Company/1234/contact/456
/Company/1234/facility/679
If there was a way to next areas that would seem like a good way, but could make the code messy.
I don't think you need to use areas
To do what you want could be done by defining routes in the global.asax for each "subcontroller" to help the engine. (I have assumed that Contact
and Facility
are separate controllers
?)
It does mean being very specific about what pattern goes to what route, but I think the below will do what you need.
Add these 2 new routes in the global asax (above the default route):
routes.MapRoute(
"ContactRoute", // Route name
"Company/{id}/Contact/{action}/{contactId}", // URL with parameters
new { controller = "Contact", action = "Index"
} // Parameter defaults
);
routes.MapRoute(
"FacilityRoute", // Route name
"Company/{id}/Facility/{action}/{facilityId}", // URL with parameters
new { controller = "Facility", action = "Index"
} // Parameter defaults
);
I'm not 100% on the code, you might need to define the contactId
and facilityId
as optional, but I hope it gives you an idea?
精彩评论