Question

I'm currently building a CMS system, and I need to have an easy way include or exclude components.

My first think was to use asp.net mvc area feature, to identified each component on itself.

But from what I see, the area feature has problems, so maybe it not that good idea.

Was it helpful?

Solution

After a few experience with area feature, I think that areas are best for something entirely different in your site, that not share the same master page with the root area.

In my case, that components are an add-ons to the root site, and share the same master page, it not best practice to use areas.

OTHER TIPS

That's so unlucky with areas referencing a common master page! Killed a day to work around this to no avail.

Probably, the trick which looks being closest to achieve the correct 'area' token for master page is described here, that is, suggesting the following snipped inside master's OnPreRender:

 var area = ViewContext.RouteData.DataTokens["area"];
 ViewContext.RouteData.DataTokens["area"] = "";
 base.OnPreRender(e);
 ViewContext.RouteData.DataTokens["area"] = area

Sadly, it didn't work for me mainly because my ActionLinks are being generated not in a master directly, but in a sibling <asp:content/>, for whch page's original area is still used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top